Search Haskell Channel Logs

Tuesday, February 21, 2017

#haskell channel featuring monochrom, ezyang, exio4, lambdabot, jle`, miscyb,

robertkennedy 2017-02-21 15:06:16
Test (sorry)
robertkennedy 2017-02-21 15:08:32
How can I check that ((,) <$> fst <*> f . snd) == fmap f?
byorgey 2017-02-21 15:10:58
robertkennedy: by "check" do you mean "test", or "prove"?
robertkennedy 2017-02-21 15:12:00
Check, I'd guess - there should be a level in ghc's cycles where the two converge
robertkennedy 2017-02-21 15:12:24
That would be a proof
byorgey 2017-02-21 15:12:53
OK. In that case, just apply both of them to an arbitrary value of type (a,b) and see that they reduce to the same result.
robertkennedy 2017-02-21 15:13:53
Hmmm.... That would work for (reverse . reverse . reverse) == reverse
byorgey 2017-02-21 15:13:56
though of course in order to do that you have to understand what fmap, <$>, and <*> do for the types in question
byorgey 2017-02-21 15:14:21
robertkennedy: not really, you would have to prove that by induction.
robertkennedy 2017-02-21 15:14:36
I want to ensure that GHC is as clever as I give it credit for
monochrom 2017-02-21 15:14:42
A test is a proof, when the statement is an existential statement.
byorgey 2017-02-21 15:15:31
robertkennedy: then I'm not sure I really understand your question. Are you asking whether those two expressions (1) have the same result, or (2) actually compile to the same code?
monochrom 2017-02-21 15:15:44
In fact, with parametricity, a test can also prove some special universal statements.
robertkennedy 2017-02-21 15:15:48
The latter
byorgey 2017-02-21 15:16:23
robertkennedy: ah. Then I suppose you want -ddump-core or something like that.
monochrom 2017-02-21 15:16:40
-ddump-simpl or -ddump-prep
byorgey 2017-02-21 15:16:48
though to be honest, I am not sure why you would care.
monochrom 2017-02-21 15:16:57
-ddump-prep is very detailed but also one of the most honest
byorgey 2017-02-21 15:17:07
interesting, I didn't know about those
exio4 2017-02-21 15:17:08
and the code might be the same today, and different tomorrow
monochrom 2017-02-21 15:17:29
I don't think there is -ddump-core. That would be too easy. :)
byorgey 2017-02-21 15:17:56
heh, you can tell how often I actually use any of these features.
robertkennedy 2017-02-21 15:18:51
I'm sure that my code is so sophisticated that GHC wouldn't recognize two similar functions.
monochrom 2017-02-21 15:19:15
-ddump-prep is the very final Core stage (right before STG --- but I don't like STG, more information overload with no benefit over Core)
monochrom 2017-02-21 15:20:18
-ddump-simpl is just before -ddump-prep. Main difference: Whereas -ddump-simpl may say "y = f (g x)", -ddump-prep spells it out as "y = let tmp1 = g x in let tmp2 = f tmp1 in tmp2"
monochrom 2017-02-21 15:21:02
So it's useful to know of both options. Sometimes you may like the more human-friendly version, some other times you want to see every bloody thunkification.
monochrom 2017-02-21 15:22:22
There are a whole bunch of more -ddump-* things that tell you the Core stages before these last two, but they are the stages when not all optimizations have finished, so their utility to end-users like me is low.
robertkennedy 2017-02-21 15:24:39
Right... If I just want to see if my newtype/data wrappers have correctly desugared (before bug hunting through core), I could create these sorts of tests. Is there architecture to support those tests? Or is it best to gain an intuition for core's ability through trial and error?
MarcelineVQ 2017-02-21 15:26:02
where is that documented monochrom? I thought, without much grounds to think so, that simpl came after prep. is prep the CoreTidy pass?
halogenandtoast 2017-02-21 15:26:16
What's the idiom for naming modules with Data in front of it. For instance I'm writing a game (that I would like to tast) so I'd like to have a bunch of stuff compiled as a library. Why would I choose to prefix the module name with Data?
halogenandtoast 2017-02-21 15:26:26
s/tast/test/
MarcelineVQ 2017-02-21 15:26:44
monochrom: Oh I see it here, nvm, thank you
MarcelineVQ 2017-02-21 15:27:21
hard to find writing about it but it does exist in an overview diagram
MarcelineVQ 2017-02-21 15:27:56
mm, there we go, in case others have interest https://ghc.haskell.org/trac/ghc/browser/ghc/compiler/coreSyn/CorePrep.hs
ezyang 2017-02-21 15:33:12
overloading interacts poorly with other features (e.g., polymorphism)
monochrom 2017-02-21 15:34:00
> (+1+1) 0
lambdabot 2017-02-21 15:34:04
error:
lambdabot 2017-02-21 15:34:04
The operator '+' [infixl 6] of a section
lambdabot 2017-02-21 15:34:04
must have lower precedence than that of the operand,
jle` 2017-02-21 15:34:52
robertkennedy: ad-hoc optimizations like that don't really scale
jle` 2017-02-21 15:35:00
and it's hard to know if constant term elimination terminates
jle` 2017-02-21 15:35:05
before actually trying it
miscyb 2017-02-21 15:35:32
what's the proper way to use frp (in my case reactive-banana) with async? example: I call async to make a thread that is constantly modifying an IORef that my main thread reads from. I'd like to do something like fire an event instead, but I don't think reactive banana allows for that.
robertkennedy 2017-02-21 15:39:05
> (+1) . (+1) $ 3
lambdabot 2017-02-21 15:39:08
5