Search Haskell Channel Logs

Friday, March 3, 2017

#haskell channel featuring ongy, phadej, alanz, jchia, yfwyfw, cocreature,

ezyang 2017-03-02 21:45:17
yeah, that's one way to do it
ezyang 2017-03-02 21:45:25
you could also use it to just define extra modules, whatever
ongy 2017-03-02 21:46:34
that's not enough to enable/disable a feature, is it? I either include the module and get a compile erorr, or don't and it's not in
ezyang 2017-03-02 21:47:30
well, it depends on who is using he dev features
ezyang 2017-03-02 21:47:35
but yes, CPP is normal
ezyang 2017-03-02 21:49:04
Conditional jump or move depends on uninitialised value(s) ==12128== at 0x421284: runInteractiveProcess
ezyang 2017-03-02 21:49:06
HMMMM
alanz 2017-03-02 21:54:51
ongy: you can have conditional hs-source-dirs, where you have a debug and non-debug version of the debug routines
alanz 2017-03-02 21:55:47
similar to https://github.com/alanz/ghc-exactprint/blob/ghc-8.2/ghc-exactprint.cabal#L92
ongy 2017-03-02 21:59:21
oh that's a nice way to do it. Not applicable for what I want to use, but I like it
alanz 2017-03-02 21:59:34
CPP is evil
ongy 2017-03-02 22:04:44
maybe what I want to do is stupid... But I want to disable a single packet (A constructor in a sum type) of my ipc that allows to bypass some checks. It's really useful for testing but a dumb idea otherwise
jchia 2017-03-02 22:05:01
Question about Data.Binary.Builder. How do I check whether a Builder is empty? I can't use (== mempty) because Builder has no Eq instance although it has a Monoid instance. Is there a better way than using (null . toLazyByteString)?
ezyang 2017-03-02 22:06:05
ongy: Sounds like you want Backpack :)
phadej 2017-03-02 22:07:14
jchia: IIRC there isn't better way, and if I think right, that shouldn't be too bad
ongy 2017-03-02 22:08:09
ezyang: I do? isn't that similar to the aproach alanz linked? (from user perspective, I bet the way it works is quite different)
ezyang 2017-03-02 22:08:39
ongy: Yeah, except with Backpack you get to typecheck without committing to an implementation :) :) :)
ezyang 2017-03-02 22:08:55
(Note: Not actually a good idea, unless you like GHC 8.2...)
alanz 2017-03-02 22:10:26
ongy: cant you declare the small version in one file and the one with the debug constructor in another, and pull them in via source dirs?
alanz 2017-03-02 22:10:35
so same file name
ongy 2017-03-02 22:10:36
my current idea is to use the MonadFail instance from cereal with an error that says "this is a dev feature" which disables one line and enables one other line. Without keeping 2 versions of the parser for everything else
ongy 2017-03-02 22:11:43
removing one of the Constructors in a sum type would break every case match that handles it, so I don't think that's a good idea
ongy 2017-03-02 22:12:56
it's not a library, so the parser *should* be the only way to get something of that type
ongy 2017-03-02 22:14:48
ezyang: why 8.2? Is that required for backpack?
ezyang 2017-03-02 22:14:54
yeah
ongy 2017-03-02 22:15:57
what's the eta on that release? I will probably want to use that for another part in the same project
ongy 2017-03-02 22:16:09
and for once I don't care much about compat to old ghc
ezyang 2017-03-02 22:16:11
well, we haven't cut the branch yet. So....
yfwyfw 2017-03-02 22:17:31
I was wondering if someone could explain me how "> (fmap . fmap) sum Just [1, 2, 3]" produce the same result as "> fmap sum $ Just [1,2,3]"
ongy 2017-03-02 22:18:21
> (fmap . fmap) sum Just [1, 2, 3]
lambdabot 2017-03-02 22:18:26
Just 6
yfwyfw 2017-03-02 22:18:33
lifting sum twice should be like "Just [sum 1, sum 2, sum 3]"
ezyang 2017-03-02 22:18:58
it's a little confusing though cuz it's not (Just [1, 2, 3])
jchia 2017-03-02 22:19:05
phadej: OK
ezyang 2017-03-02 22:19:14
> map @Int (+2) [1,2]
lambdabot 2017-03-02 22:19:18
error:
lambdabot 2017-03-02 22:19:18
Pattern syntax in expression context: map@Int
lambdabot 2017-03-02 22:19:18
Did you mean to enable TypeApplications?
ezyang 2017-03-02 22:19:24
drat! No type applications
yfwyfw 2017-03-02 22:20:50
lifting sum twice should be like "Just [sum 1, sum 2, sum 3]" instead of "Just (sum [1, 2, 3])"
ezyang 2017-03-02 22:21:31
that's not what it's doing
ezyang 2017-03-02 22:21:44
@pl (fmap . fmap) sum Just [1, 2, 3]
lambdabot 2017-03-02 22:21:45
fmap sum (Just [1, 2, 3])
ongy 2017-03-02 22:22:08
:t (fmap . fmap) sum
lambdabot 2017-03-02 22:22:12
(Foldable t, Num b, Functor f1, Functor f) => f (f1 (t b)) -> f (f1 b)
ongy 2017-03-02 22:22:27
ok that looks worse than I expected
ezyang 2017-03-02 22:22:42
so f is gonna be function
ezyang 2017-03-02 22:22:48
cuz the next argument is Just
ezyang 2017-03-02 22:23:10
> 2 :: _
ongy 2017-03-02 22:23:12
maybe we should mention that there's Monad/Applicative/Functor instances for ((->) a)
lambdabot 2017-03-02 22:23:14
error:
lambdabot 2017-03-02 22:23:14
• No instance for (Num t1)
lambdabot 2017-03-02 22:23:14
Possible fix:
yfwyfw 2017-03-02 22:23:47
ah.
yfwyfw 2017-03-02 22:23:54
right
yfwyfw 2017-03-02 22:24:02
Now I know what you mean
ongy 2017-03-02 22:24:21
:t fmap fmap fmap -- This is the example that comes up from time to time and confuses people (sometimes including me)
yfwyfw 2017-03-02 22:24:23
Thank you very much :)
lambdabot 2017-03-02 22:24:24
(Functor f1, Functor f) => (a -> b) -> f (f1 a) -> f (f1 b)
yfwyfw 2017-03-02 22:24:59
happy again
cocreature 2017-03-02 22:34:16
"fmap fmap fmap max max" is the maximum function on three numbers :)
yfwyfw 2017-03-02 22:38:51
that's now a proper type tetris.. I must play a lot
cocreature 2017-03-02 22:39:14
yfwyfw: be careful, it's addictive
yfwyfw 2017-03-02 22:39:25
:)