Search Haskell Channel Logs

Saturday, March 4, 2017

#haskell channel featuring xubunto, mekeor, AWizzArd, Rembane, Theophane, byorgey, and 9 others.

Theophane 2017-03-04 09:45:20
Zemyla: okay cool :) thanks for the tip!
Tuplanolla 2017-03-04 09:47:53
Hmm, indeed.
Zemyla 2017-03-04 09:49:32
I'm having to save 2 or 3 21-bit Unicode Chars to a single Word64.
mekeor 2017-03-04 09:57:20
what do symbols in lispy languages do? – explained for haskellers? what do correlate to in haskell?
Rembane 2017-03-04 09:57:49
I want to count the number of constructors in a data type programmatically, how do I do that?
lyxia 2017-03-04 09:58:16
Rembane: generics or template haskell
mekeor 2017-03-04 09:58:42
lyxia: you cound use the Bound type class i think?
glguy 2017-03-04 09:58:46
:t length . dataTypeConstrs . dataTypeOf
lambdabot 2017-03-04 09:58:49
Data a => a -> Int
mekeor 2017-03-04 09:58:50
@src Bound
lambdabot 2017-03-04 09:58:51
Source not found. Wrong! You cheating scum!
Rembane 2017-03-04 09:59:49
lyxia, mekeor, glguy: Thank you!
mekeor 2017-03-04 10:00:35
@src Bounded -- that's what it's called
lambdabot 2017-03-04 10:00:36
Source not found. Are you typing with your feet?
xubunto 2017-03-04 10:00:56
i like this lambda bot
mekeor 2017-03-04 10:01:15
yes, but i'm too stupid to use it
xubunto 2017-03-04 10:01:43
it is a sassy bot
xubunto 2017-03-04 10:01:45
:D
lyxia 2017-03-04 10:02:23
mekeor: doesn't bounded only allow you to count values?
Cale 2017-03-04 10:05:41
mekeor: They're roughly like nullary data constructors
Cale 2017-03-04 10:06:53
mekeor: They're just values which can cheaply be compared for equality (though not necessarily ordering)
okeuday_bak 2017-03-04 10:16:40
After base-4.3, using fail "string" :: Either String a causes an error exception, is there an alternative that doesn't create an exception?
byorgey 2017-03-04 10:18:01
okeuday_bak: Left "string" ?
okeuday_bak 2017-03-04 10:18:44
byorgey: yeah, problem #4 at http://blog.ezyang.com/2011/08/8-ways-to-report-errors-in-haskell-revisited/
byorgey 2017-03-04 10:21:04
okeuday_bak: that blog post is from 5 1/2 years ago. I don't think anyone at all advocates the use of 'fail' these days.
okeuday_bak 2017-03-04 10:21:21
byorgey: k, good to know
okeuday_bak 2017-03-04 10:22:45
byorgey: it seems best to avoid, is there something better than "Either CustomEnumerableType" for code that wants to avoid IO/exceptions, or is that best?
Zemyla 2017-03-04 10:30:10
byorgey: Lots of people use it implicitly in list comprehensions.
byorgey 2017-03-04 10:31:25
Zemyla: that's true
deech 2017-03-04 10:35:41
Hi all, this is a dumb question but how do I write a newline character to a file? I'm trying to write "hello\nworld" but having no success with 'writeFile blah "hello\\nworld", "hello\\\nworld" or "hello\\\\nworld".
geekosaur 2017-03-04 10:36:05
you wanted the one you didn't try. \n
AWizzArd 2017-03-04 10:36:41
In main (i.e. inside an IO do block) I would like to call a pure function, which returns a Bool. What I did was x <- return (myFn data) and in the next line I had to putStrLn x, so that it would actually get evaluated.
deech 2017-03-04 10:36:41
That saves it as "hello world"
deech 2017-03-04 10:36:56
I want "hello\nworld".
geekosaur 2017-03-04 10:37:05
\\n
AWizzArd 2017-03-04 10:37:11
Can I call myFn in a way that it *does* get evaluated, but the result will be thrown away?
deech 2017-03-04 10:37:25
That gets me "hello\ world".
geekosaur 2017-03-04 10:37:34
that sounds very wrong
AWizzArd 2017-03-04 10:37:40
(I just want to time it via getCPUTime)
mekeor 2017-03-04 10:37:46
ddeech: try "
mekeor 2017-03-04 10:37:46
"
geekosaur 2017-03-04 10:37:52
> "hello\\nworld"
lambdabot 2017-03-04 10:37:55
"hello\\nworld"
geekosaur 2017-03-04 10:38:06
> text "hello\\nworld"
lambdabot 2017-03-04 10:38:09
hello\nworld
mekeor 2017-03-04 10:38:33
> show "hello\\nworld"
lambdabot 2017-03-04 10:38:36
"\"hello\\\\nworld\""
geekosaur 2017-03-04 10:38:38
AWizzArd, what you wrote was the same as "let x = myFn data" and neither one forces evaluation
geekosaur 2017-03-04 10:38:53
"let !x = myFn data" will force at least partial evaluation
AWizzArd 2017-03-04 10:39:06
geekosaur: okay, I will give this a try, thx
geekosaur 2017-03-04 10:39:25
you may need an extension (BangPatterns)
geekosaur 2017-03-04 10:42:01
AWizzArd, also, timing stuff in Haskell is really hairy because of laziness.You want to look at the criterion package.
geekosaur 2017-03-04 10:42:14
it deals with most of the hairy edge cases
AWizzArd 2017-03-04 10:42:42
geekosaur: yes of course, true benchmarking is what is really the right way to go here. But in this case my goal is to simply play around with basic newbie Haskell stuff
geekosaur 2017-03-04 10:43:11
right, but the edge cases caused by laziness are bad enough that criterion is really needed even for basic/quick timings
geekosaur 2017-03-04 10:43:24
that was originally why it was written
geekosaur 2017-03-04 10:43:42
not benchmarking, just handling all the edge cases
AWizzArd 2017-03-04 10:44:25
Makes sense. In my case here it's okay though, because I am not really very interested in the timings and don't need accuracy.
AWizzArd 2017-03-04 10:44:33
Just trying to get ideas to compile.