Search Haskell Channel Logs

Monday, February 27, 2017

#haskell channel featuring blackhole1, robertkennedy, tommd, Squarism, lambdabot, glguy,

blackhole1 2017-02-27 13:52:59
3
blackhole1 2017-02-27 13:53:20
quit
spaceghost 2017-02-27 14:16:16
Hello clint.
robertkennedy 2017-02-27 14:20:26
> (fail "test" :: Monad m => m Int) :: Either String Int
lambdabot 2017-02-27 14:20:28
*Exception: test
robertkennedy 2017-02-27 14:20:39
What is that?!?!
tommd 2017-02-27 14:21:37
spaceships: Ping
glguy 2017-02-27 14:22:10
robertkennedy: What else would you expect it to be?
jle` 2017-02-27 14:23:26
robertkennedy: look at the Monad instance for Either
jle` 2017-02-27 14:24:59
(spoilers: it just leaves the defailt implementation of fail = errorWithoutStackTrace
glguy 2017-02-27 14:25:33
Without looking in the code you can see the output of :i Monad
glguy 2017-02-27 14:25:34
instance Monad (Either e)
robertkennedy 2017-02-27 14:25:57
Sure, I get that the general `instance Monad (Either a)` can't have fail go to `Left`
glguy 2017-02-27 14:25:59
The instance works for all 'e' equally
jle` 2017-02-27 14:26:17
robertkennedy: so, you understand what's going on
glguy 2017-02-27 14:26:36
so it would be upsetting if fail at the type Either String Int did anything other than what it did
jle` 2017-02-27 14:27:14
parametric polymorphism at its finest
glguy 2017-02-27 14:27:27
I suppose you could do: fail = Left . error
glguy 2017-02-27 14:27:39
but I don't think that would be an improvement
jle` 2017-02-27 14:27:41
lol
jle` 2017-02-27 14:27:54
isLeft would work i suppose
spaceghost 2017-02-27 14:28:24
Pong tommd.
tommd 2017-02-27 14:29:33
Ohh, free pong.
tommd 2017-02-27 14:29:47
(I was actually looking for space-ships)
robertkennedy 2017-02-27 14:29:56
Of course I knew why when I debugged it. But I don't know Whyyyyy
robertkennedy 2017-02-27 14:32:19
Like if you had `instance FromString a -> Monad (Left a)`, imagine the utility
glguy 2017-02-27 14:32:46
The utility of only being able to use it with types that were instances of FromString?
glguy 2017-02-27 14:33:03
That'd break most of the times that I use it
robertkennedy 2017-02-27 14:33:06
(until the MonadFail proposal)
glguy 2017-02-27 14:33:09
but if you want that, it exists
glguy 2017-02-27 14:33:29
http://hackage.haskell.org/package/transformers-0.5.4.0/docs/Control-Monad-Trans-Error.html
glguy 2017-02-27 14:33:33
It's just usually not what people want
Squarism 2017-02-27 14:36:35
glguy, Just got to thank you again. Separating lib/executables/tests into different source roots relieved me from restating lib dependencies (like 30) for 4 artifacts + "other-modules" repetition. Starting to like cabal almost
Squarism 2017-02-27 14:36:51
+ made my build 4 times faster
glguy 2017-02-27 14:36:56
yay ^_^
Squarism 2017-02-27 14:37:14
=D
robertkennedy 2017-02-27 14:42:06
You're right that the FromString constraint is silly - ie parsers