tsahyt 2017-02-01 21:48:10
hmm, using foldl' over foldr didn't help at all. so strictness is probably not the issue then I suppose
cocreature 2017-02-01 21:49:13
tsahyt: decreasing the stack size is a pretty good way to check if you have a spaceleak caused by insufficient strictness
cocreature 2017-02-01 21:49:23
there are some false positives but they are usually easy to spot
nhooyr 2017-02-01 21:50:09
what are the best resources for learning haskell? https://www.haskell.org/documentation has many and I'm not sure which to choose
tsahyt 2017-02-01 21:50:36
I'm using the entire result right afterwards. Besides I've done some memory profiling already and it looked reasonably alright
tsahyt 2017-02-01 21:52:24
cocreature: what would be a low enough value to check? it runs fine with -K1M
cocreature 2017-02-01 21:52:48
tsahyt: I usually run with -K1K
cocreature 2017-02-01 21:53:00
I stole that from neil mitchell
ski 2017-02-01 21:53:37
nhooyr : i learned from "Haskell: The Craft of Functional Programming", by Simon Thompson
tsahyt 2017-02-01 21:53:39
that does not run, but I don't even get to the critical part of the program with it
nhooyr 2017-02-01 21:53:57
ski: thanks
cocreature 2017-02-01 21:54:04
tsahyt: I then use -xc to figure out where it's failing
cocreature 2017-02-01 21:54:26
tsahyt: but if your memory usage is not unreasonably high it's probably not worth the effort
ski 2017-02-01 21:54:35
@where CIS194
lambdabot 2017-02-01 21:54:35
http://www.seas.upenn.edu/~cis194/spring13/
ski 2017-02-01 21:54:55
nhooyr : ^ also seems to be often suggested, nowadays
ski 2017-02-01 21:55:05
and then
ski 2017-02-01 21:55:06
@where NICTA
lambdabot 2017-02-01 21:55:07
https://github.com/nicta/course
tsahyt 2017-02-01 21:55:12
cocreature: usually it isn't. but in general this is some very very expensive stuff I'm doing here, so it might become an issue on large instances.
tsahyt 2017-02-01 21:55:16
I think it's worth checking it out anyhow
ski 2017-02-01 21:55:21
nhooyr : you could possible also try
ski 2017-02-01 21:55:25
@where HaskellBook
lambdabot 2017-02-01 21:55:25
http://haskellbook.com
cocreature 2017-02-01 21:55:40
tsahyt: the most important false positive is mapM/sequence.
ski 2017-02-01 21:56:01
nhooyr : and #haskell-beginners, which goes together with that book. though note that beginner/newbie questions are also welcome in this channel
cocreature 2017-02-01 21:56:01
(mapM_ is not affected)
tsahyt 2017-02-01 21:56:06
false positive in what sense?
nhooyr 2017-02-01 21:56:17
ski: thanks for all the help!
ski 2017-02-01 21:56:21
nhooyr : if you like pretty pictures
ski 2017-02-01 21:56:24
@where LYAH
lambdabot 2017-02-01 21:56:24
http://www.learnyouahaskell.com/
cocreature 2017-02-01 21:56:36
tsahyt: in the sense that insufficient strictness is not the reason why it's using more stack space
nhooyr 2017-02-01 21:56:36
and it's free online :D
ski 2017-02-01 21:56:46
nhooyr : but i've heard people saying that it doesn't really explain things that well. you could try it a little, i guess
tsahyt 2017-02-01 21:57:05
alright. so far any strictness annotations have only made it worse.
tsahyt 2017-02-01 21:57:29
I'm mostly looking at time here rather than space.
tsahyt 2017-02-01 21:58:18
hmm, no this benchmark reports 39MB total memory. space is alright I guess.
cocreature 2017-02-01 21:59:26
tsahyt: so is it just being slower than you would like/expect it to be?
tsahyt 2017-02-01 21:59:31
yes, much slower
tsahyt 2017-02-01 22:00:26
and profiling suggests that most of the time goes into things other than the main chunk of the work, which I've paid very close attention to while implementing
cocreature 2017-02-01 22:00:27
tsahyt: running with "+RTS -s" gives you a productivity value that can sometimes be helpful to make sure that it's your program being slow and not your program being slowed down by the GC
tsahyt 2017-02-01 22:00:40
91.5% productivity. not ideal.
cocreature 2017-02-01 22:00:49
not that bad either
tsahyt 2017-02-01 22:01:08
could be worse, yeah. profiling suggests that most of the time is spent updating this priority queue
tsahyt 2017-02-01 22:01:25
well, it's the cost center for the new queue to be precise
tsahyt 2017-02-01 22:02:28
hmm, when inlining happens, can that "merge" cost centers?
cocreature 2017-02-01 22:02:48
I think so
tsahyt 2017-02-01 22:03:23
right, that opens up some more possibilities then. The fold can't possibly be the problem I think.
tsahyt 2017-02-01 22:03:29
especially not when it behaves the same with a strict fold
tsahyt 2017-02-01 22:04:12
worst case, it's just slow because it happens *a lot*, several hundred of million times throughout the benchmark
tsahyt 2017-02-01 22:04:21
but it's worth investigating I think
tsahyt 2017-02-01 22:05:30
cocreature: btw, thanks for the lrucaching package again, it's helping a lot in making this fast
cocreature 2017-02-01 22:05:55
tsahyt: I'm happy you find it useful. if you have any suggestions for improvements I'm all ears :)
mbuf 2017-02-01 22:08:11
ski, does the Haskell Book also have answers to exercises?
ski 2017-02-01 22:08:34
mbuf : i don't know, ask in #haskell-beginners
mbuf 2017-02-01 22:09:15
ski, okay
ski 2017-02-01 22:10:38
nhooyr : perhaps also see ,. by the author of HaskellBook, ,, might be interesting
ski 2017-02-01 22:11:39
nhooyr : also make sure to ask questions here (or #haskell-beginners or both), or on the mailing list. we generally try to be a helpful bunch
ski 2017-02-01 22:12:01
(s/the author/one of the authors/)
tsahyt 2017-02-01 22:13:15
cocreature: the only "issue" I had related to it was that it would build up more memory than I thought was necessary at first. my keys are HashSets, and it of course needs to hold on to the entire thing rather than just the hash in case of collisions, so I think there's not much you can do there.
tsahyt 2017-02-01 22:13:44
but the memory usage tapers off after a while of course, and it's not preposterous. it's just the normal space/time tradeoff you make when employing a cache to begin with.
cocreature 2017-02-01 22:14:17
yeah I don't think I can do anything about that
nhooyr 2017-02-01 22:14:40
ski: will do thanks
tsahyt 2017-02-01 22:14:52
it's not a problem, it was just a bit confusing when I started profiling and the heap profile reported a buildup from the function building those hash sets
ski 2017-02-01 22:16:10
( , by the other author might also be interesting)
Tspoon 2017-02-01 22:17:15
nhooyr: as a complete haskell newbie, I have found LYAH a beginner friendly introduction to the language. it might cut some corners, but at least it is usually made clear when that happens
nhooyr 2017-02-01 22:25:14
ok thanks
kmelva 2017-02-01 22:29:24
if I have in a do block `foo <- doFoo`, how can I add a type annotaion what should foo be?
kmelva 2017-02-01 22:29:38
just doing `foo :: BlahBlah <- doFoo` trows errors...
mutsig 2017-02-01 22:30:15
Type annotations should come after the expression
tsahyt 2017-02-01 22:32:16
Tspoon: I think that's alright. Just like you learn how to do arithmetic so you can do useful things long before you learn about how numbers have group structure etc. Learning is a kind of iterative deepening process imo.
kmelva 2017-02-01 22:32:53
mutsig: but then... it sets the type for the expression right of the `<-`
kmelva 2017-02-01 22:33:15
I want to annotate foo, which is no longer IO a, but just a
kmelva 2017-02-01 22:33:25
I don't know if I'm making myself clear :)
roxxik 2017-02-01 22:37:50
kmelva: you can't have that ;)
roxxik 2017-02-01 22:38:02
(at least the last time i tried)
kmelva 2017-02-01 22:38:28
roxxik: aaaaaawh, too bad... well, not that big of deal to stick IO in front... thanks you guys :)
tsahyt 2017-02-01 22:39:09
yes you can
tsahyt 2017-02-01 22:39:22
you'll need ScopedTypeVariables though
kmelva 2017-02-01 22:41:18
ah well, still not worth it... I still have fear of extensions :)
tsahyt 2017-02-01 22:41:50
kmelva: scoped type variables is nothing scary, and doesn't break anything to the best of my knowledge.
mutsig 2017-02-01 22:44:34
imo, avoiding extensions is a good thing if you don't really need them.
roxxik 2017-02-01 22:44:44
kmelva: i'm really not sure right now if it broke for me because of ScopedTypeVariables or other stuff, but you can try using a concrete type, if it works, then `a` not working is really a ScopedTypeVariable thing