Search Haskell Channel Logs

Tuesday, February 28, 2017

#haskell channel featuring ertes, byorgey, merijn, leshow, Arguggi, mehs,

orion 2017-02-28 03:20:41
If a thread created by forkIO throws an exception that is not caught, will it take down the whole application?
Arguggi 2017-02-28 03:32:31
orion, no you should only get some text on stderr (something like program-name: excep-message) iinm
merijn 2017-02-28 03:34:27
The real answer is: "It Depends"
merijn 2017-02-28 03:34:36
Since you can overwrite the default exception handler
ertes 2017-02-28 03:35:33
merijn: how?
ertes 2017-02-28 03:35:39
by not using criterion? =)
Aruro 2017-02-28 03:35:51
is it possible to use unicode fraction slash to create custom fractions (using ghc putStr) ?
merijn 2017-02-28 03:36:00
ertes: Well, no, my problem was with the batching, right? Well, I realised I can work around that
merijn 2017-02-28 03:37:05
ertes: Normally criterion does batching (if you use nfIO, nf, whnf, etc.) by wrapping a loop around your workload and calling that in a batch (running your benchmark N times per batch)
merijn 2017-02-28 03:37:54
ertes: If you use the Benchmarkable constructor directly, your benchmark can basically by-pass this batching loop, as long as it accepts some input N that increases your benchmarks size
merijn 2017-02-28 03:38:22
ertes: Then, instead of treating it as batches of N being run, you can treat it a batch as a single benchmark of variable size
leshow 2017-02-28 03:38:28
i'm writing a traversable instance for List, just to practice. I have it written the traditional way with fmap and applicative. out of curiousity i wanted to write it with the applicativedo notation
leshow 2017-02-28 03:38:42
however ghc tells me "cannot deduce monad f arising from do statement"
leshow 2017-02-28 03:39:00
is there a way to get ghc to use only the applicative instance for my definition
merijn 2017-02-28 03:39:06
ertes: So, instead of writing 1 message to the channel, just write a benchmark the concurrently writes some N messages and have criterion parameterise it to figure out how large N should be for useful measurements
merijn 2017-02-28 03:39:21
ertes: Then you only have to do setup/cleanup per batch
Aruro 2017-02-28 03:42:43
this guide tells that it is possible to create any unicode fraction using super,subsrcipts and fraction slash http://unicodefractions.com/
Aruro 2017-02-28 03:43:00
but tests in ghc does not confirm it working in haskell
merijn 2017-02-28 03:44:48
Define not working?
Aruro 2017-02-28 03:45:09
fraction slash is shown as box in uxterm
Aruro 2017-02-28 03:45:14
emacs displays it correctly
benzrf 2017-02-28 03:45:25
...that doesnt sound like a haskell issue
merijn 2017-02-28 03:45:25
Sounds like uxterm or your locale is misconfigured
benzrf 2017-02-28 03:45:29
it sounds like a uxterm issue
Aruro 2017-02-28 03:45:38
sub and superscripts work just fine
merijn 2017-02-28 03:45:39
And/or your font missing a glyph
ertes 2017-02-28 03:45:45
merijn: ah, nice
ertes 2017-02-28 03:46:08
leshow: did you actually use -XApplicativeDo?
ertes 2017-02-28 03:46:18
e.g. via {-# LANGUAGE ApplicativeDo #-}
leshow 2017-02-28 03:46:23
ertes, yes i have it enabled at the top
ertes 2017-02-28 03:46:34
leshow: then paste your code
ertes 2017-02-28 03:47:10
ApplicativeDo is highly sensitive to things that could in principle be expressed using Applicative, but isn't quite in the right form
Aruro 2017-02-28 03:48:10
can some one confirm unicode fraction slash working for him?
Aruro 2017-02-28 03:48:59
in terminal, using putStr
ertes 2017-02-28 03:49:38
Aruro: you mean as a character/string literal?
merijn 2017-02-28 03:49:45
Works fine if I run 'putStr "¼"' in ghci
leshow 2017-02-28 03:49:53
sorry about that ertes
leshow 2017-02-28 03:50:01
lpaste.net/353061
ertes 2017-02-28 03:50:32
leshow: i suspect that the ($) is your problem
ertes 2017-02-28 03:50:42
try: return (Cons a b)
ertes 2017-02-28 03:50:53
or even, to be actually consistent with Applicative: pure (Cons a b)
leshow 2017-02-28 03:50:55
huh yeah that worked
Aruro 2017-02-28 03:51:11
merijn: its not unicode fraction slash
ertes 2017-02-28 03:51:17
leshow: the problem is that ApplicativeDo expects the expression to be in this form: pure x
leshow 2017-02-28 03:51:17
why would function app operator make it choose the monad instance
ertes 2017-02-28 03:51:23
but yours is in this form: ($) pure x
ertes 2017-02-28 03:51:28
so ($) is the top-level function
leshow 2017-02-28 03:51:47
oh ok, that makes sense. thank you
ertes 2017-02-28 03:51:51
it also teaches you not to over-use ($) =)
Aruro 2017-02-28 03:52:14
ertes: yes, if i understood correctly form like SUPERSCRIPT FRACTIONSLASH SUBSCRIPT can form any custom unicode fraction as one symbol
leshow 2017-02-28 03:52:17
i prefer the fmap and apply for this instance anyway, but it puzzled me why it wouldnt work
ertes 2017-02-28 03:52:53
ApplicativeDo is particularly useful with record stuff, especially together with RecordWildCards
ertes 2017-02-28 03:53:09
do field1 <- c1; field2 <- c2; field3 <- c3; pure MyConstr{..}
ertes 2017-02-28 03:53:48
for: data MyType = MyConstr { field1 :: A, field2 :: B, field3 :: C }
ertes 2017-02-28 03:54:33
there is simply no nice way to write this using the Applicative combinators, unless you stop using the field names =)
leshow 2017-02-28 03:54:45
does record wild cards put do the field1 = field1, ... there automatically?
ertes 2017-02-28 03:54:51
yeah
leshow 2017-02-28 03:54:58
that's pretty cool
ertes 2017-02-28 03:55:17
it will use whatever is in scope and has that name
ertes 2017-02-28 03:55:41
so this works as well: f field1 = do field2 <- c2; field3 <- c3; pure MyConstr{..}
leshow 2017-02-28 03:55:56
i thought it was only useful for pattern matching on the left side in fn arguments
leshow 2017-02-28 03:56:46
so it's better to explicitly use pure instead of return when i use applicativedo? the ghc.haskell page on the ext used return
lyxia 2017-02-28 03:57:08
I thought you were supposed to use return
leshow 2017-02-28 03:57:15
i mean it makes sense of course, i just didnt see it the ghc page
leshow 2017-02-28 03:57:24
https://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo
byorgey 2017-02-28 03:58:18
I'm sure with ApplicativeDo turned on it makes no difference whether you use 'return' or 'pure'
lyxia 2017-02-28 04:00:36
Right I just tested it.
ertes 2017-02-28 04:01:20
it has worked with 'pure' for me in the past, too… that's why i suggested it
lyxia 2017-02-28 04:02:50
I guess I confused it with another gotcha of ApplicativeDo...
mehs 2017-02-28 04:18:13
Hello, was wondering what the is generally considered the 'best' JetBrains IDE plugin for Haskell
leshow 2017-02-28 04:18:56
is there more than one?
mehs 2017-02-28 04:20:01
Yeah, JetBrains repo one, HaskForce and IntelliJ-Haskell