Search Haskell Channel Logs

Saturday, February 18, 2017

#haskell channel featuring mckeankylej, ReinH, maybefbi, Cale, Cooler, qmm,

qmm 2017-02-18 16:49:30
:info (->)
qmm 2017-02-18 16:49:43
data (->) t 1 -- Defined in 'GHC.Prim'
qmm 2017-02-18 16:50:01
i don't see it defined at https://hackage.haskell.org/package/ghc-prim-0.4.0.0/candidate/docs/src/GHC-Prim.html
geekosaur 2017-02-18 16:51:05
things sometimes move around; make sure you are checking the version that your ghci is using. (I would be surprised if it is a candidate release)
geekosaur 2017-02-18 16:52:00
in particular, I think changes related to the new Typeable coming in 8.2.1 caused it to move (possibly into base?)
qmm 2017-02-18 16:52:09
ah, ghc 8.0.1 instead of 8.0.2
geekosaur 2017-02-18 16:52:49
hm, actually
geekosaur 2017-02-18 16:53:52
I think it is not there because it is special. if it can be described (not defined!) in Haskell then it'll show up there. some things are so primitive they are wired in and can't have a stub in GHC.Prim, and haddock can't document them as a result
geekosaur 2017-02-18 16:55:35
right, not in the haddock for 8.0.1 either, it's probably too primitive to have a Haskell stub for haddock to hang docs off of
qmm 2017-02-18 16:56:34
geekosaur: there's no definition of (->) then?
geekosaur 2017-02-18 16:56:54
not in Haskell syntax
geekosaur 2017-02-18 16:57:01
there are no actual definitions in GHC.Prim
geekosaur 2017-02-18 16:57:33
just fake ones that all resolve to "let x = x in x"; GHC.Prim is documentation stubs for things that are built in to the compiler and/or runtime
geekosaur 2017-02-18 16:57:58
as for (->), you can't even describe it properly using Haskell syntax, so not even a documentation stub
geekosaur 2017-02-18 16:58:50
(part of the problem is (->) is too polymorphic for its type to be described properly; what ghci shows is a slight lie, although not as much of one as it was in 6.x and 7.x)
geekosaur 2017-02-18 16:59:21
(and the type level one's kind similarly can't be described, at least pre-8.0 and possibly still not)
qmm 2017-02-18 16:59:21
it is function application, right?
geekosaur 2017-02-18 16:59:32
no
geekosaur 2017-02-18 16:59:47
($) is function application. (->) is function *definition*
qmm 2017-02-18 16:59:59
that makes sense
qmm 2017-02-18 17:00:22
i've only seen it in type signatures
qmm 2017-02-18 17:01:52
i like to imagine this is you on the other of the keyboard when i say things like "it is funciton application, right" https://www.youtube.com/watch?v=e5Lx9bH0n1E
qmm 2017-02-18 17:02:33
thanks for your help!
Cooler 2017-02-18 17:02:52
can you only write deriving for data?
Cooler 2017-02-18 17:03:03
or can you derive for newtype?
geekosaur 2017-02-18 17:03:36
you can derive for newtype, but it requires an extension
qmm 2017-02-18 17:03:52
-XGeneralizedNewtypeDeriving
geekosaur 2017-02-18 17:04:01
and it works differently: newtype deriving exposes specific instances from the underlying type
geekosaur 2017-02-18 17:04:32
(for Show and Read it modifies them slightly, so it acts a little more like deriving for data)
ReinH 2017-02-18 17:06:52
(->) is special notation for function type, just like [a] is special notation for [] a and (a,b) is special notation for (,) a b
ReinH 2017-02-18 17:08:35
It's special syntax.
lpaste_ 2017-02-18 17:09:33
maybefbi pasted "The result should be [True, True, False, False, False, True]" at http://lpaste.net/1650252320614645760
maybefbi 2017-02-18 17:09:53
can anyone help me with this ^
maybefbi 2017-02-18 17:10:34
i can't seem to update the state
ReinH 2017-02-18 17:10:38
maybefbi: don't use isNothing and fromJust, use pattern matching
maybefbi 2017-02-18 17:10:53
ok will do. but the bug is the state doesnt update
ReinH 2017-02-18 17:11:36
that just happens to work because || False is non-strict
ReinH 2017-02-18 17:11:47
er, (||) False
maybefbi 2017-02-18 17:12:49
uhm it doesnt work. i mean it doesnt return the expected result
maybefbi 2017-02-18 17:13:07
the LogState is not updated
ReinH 2017-02-18 17:13:26
I mean work as in "doesn't cause a runtime error"
maybefbi 2017-02-18 17:13:50
ok. but im trying to get the expected result
maybefbi 2017-02-18 17:14:29
not avoid runtime errors which does not exist
ReinH 2017-02-18 17:15:37
Why are you using Map.update instead of Map.insert when you always insert?
ReinH 2017-02-18 17:16:03
maybe if this was written more simply, the issue would be easier to find
maybefbi 2017-02-18 17:16:37
if the key already exists and i chose to print into log, i need to update the time the log entry was last printed
ReinH 2017-02-18 17:16:42
Also, what result *do* you get?
ReinH 2017-02-18 17:16:48
insert overwrites
ReinH 2017-02-18 17:17:03
it's literally the same as what you're doing without the unnecessary complexity
maybefbi 2017-02-18 17:17:08
[True,True,True,True,True,True]
maybefbi 2017-02-18 17:17:13
is the result i get
ReinH 2017-02-18 17:17:21
(well, it doesn't overwrite in place, ofc, it returns a new map with that key changed)
mckeankylej 2017-02-18 17:20:37
Hey everyone I have a piece of code that uses scoped type variables, but I dont like that as it pollutes the haddocks with foralls. Is there a better way of doing the following code: http://lpaste.net/352700
maybefbi 2017-02-18 17:21:53
ReinH, hmm using insert seems to make a change. seems like update only updates if the key is already in the map
ReinH 2017-02-18 17:23:06
Ah, good catch
ReinH 2017-02-18 17:23:14
So it's never adding your values
ReinH 2017-02-18 17:23:25
because you start with an empty map
maybefbi 2017-02-18 17:24:17
ReinH, yeah
Cale 2017-02-18 17:24:48
mckeankylej: I generally wouldn't worry about it.
Cale 2017-02-18 17:26:06
There's probably some much uglier thing you can do by introducing a bunch of dead code...
Cale 2017-02-18 17:27:00
But this is pretty much exactly the sort of situation which ScopedTypeVariables exists for
ReinH 2017-02-18 17:27:30
Instead of worrying about the foralls, we suggest not worrying about the foralls.
ReinH 2017-02-18 17:28:26
maybefbi: so I was right about switching to insert, but only by accident.
maybefbi 2017-02-18 17:29:17
ReinH, only partially. the last element of the result array is still wrong. im inspecting why
mckeankylej 2017-02-18 17:30:42
ReinH: would you want a patch to haddocks to not pretty print top level foralls?
maybefbi 2017-02-18 17:32:26
ReinH, seems like that last issue was because test case says to print at the 11th second even if there was a print at the 1st second
Cale 2017-02-18 17:33:53
mckeankylej: You may be able to get away with using the C preprocessor to define the function differently while building the haddocks
Cale 2017-02-18 17:34:16
But I'm not sure it's worth the trouble, tbh. Explicit foralls are so common that they don't bother me.
mckeankylej 2017-02-18 17:35:50
Cale: ho boy that feels like bringing a nuke to a knife fight, and it would make the code much harder to read. Thanks though!