Search Haskell Channel Logs

Thursday, February 9, 2017

#haskell channel featuring lienz, dima-h, ph88_, eschnett, reactormonk, Rodenbach, and 7 others.

cocreature 2017-02-09 05:48:03
nut: "stack exec ghc-pkg -- list" should work iirc
srhb 2017-02-09 05:48:08
nut: Something like stack exec ghc-pkg -- --list maybe
srhb 2017-02-09 05:48:13
Woops, too slow
srhb 2017-02-09 05:48:28
And wrong, too! :(
reactormonk 2017-02-09 05:50:56
So I've written https://stackoverflow.com/questions/42126267/compile-time-checked-uris/42126648 - how woud I write a test for it?
nut 2017-02-09 05:53:35
srhb: thx i think it works
Rodenbach 2017-02-09 05:55:52
I defined a tree like this: data Tree a = Empty | Node { val :: a, left :: Tree a, right :: Tree a} deriving (Show, Read, Eq, Ord)
Rodenbach 2017-02-09 05:55:55
When I now create a Node 100 Empty Empty ghci prints Node {val = 10, left = Empty, right = Empty} – given a Node instance, how can I get the field names "val", "left" and "right"?
dima-h 2017-02-09 05:56:25
hello everyone!!
lienz 2017-02-09 05:59:44
I'm looking for some advice about how to map a non-deterministic function over an (unboxed) array
lienz 2017-02-09 06:00:03
I'd like some sort of map function, of type (a -> Random b) -> Array a -> Random (Array b)
lienz 2017-02-09 06:01:03
at the moment I'm using repa, mostly because its support of multidimensional arrays makes it easy to work with
cocreature 2017-02-09 06:01:40
lienz: I don't know anything about repa but generally these kind of functions are called "mapM"
lienz 2017-02-09 06:02:16
yeah I know that but repa doesn't have that, because IO messes with parallelisability
lienz 2017-02-09 06:02:23
repa has some "traverse" function (which is different from a traversable "traverse"), which I'm currently using to map my non-deterministic function over the array
lienz 2017-02-09 06:02:54
but to do that I'm using an unsafePerformIO
lienz 2017-02-09 06:03:16
ideally yeah, I'd want a mapM or a Data.Traversable.traverse
eschnett 2017-02-09 06:04:03
lienz: usually, random number generators are inherently serial, i.e. they cannot be parallelized
eschnett 2017-02-09 06:04:26
lienz: if so, you'd be stuck with generating a regular list of Random b, and than create a repa array from that
benzrf 2017-02-09 06:04:38
are there really any haskell solutions for presenting an interactive GUI for editing a tree, that come anywhere near the usability of mutable trees that support references to nodes?
novakboskov 2017-02-09 06:05:16
Hi everyone, I'm trying to reproduce foldl and foldl' from https://wiki.haskell.org/Foldr_Foldl_Foldl' and have no success. Both of them cause stack overflow with [1..10000000] and both produce result with one magnitude smaller list [1..1000000]...
lienz 2017-02-09 06:05:27
eschnett: but I don't really care about any kind of determinism; is there a way to initialise the various parallel threads with a seed and have them each do their thing?
lienz 2017-02-09 06:05:46
one issue is that I don't know ahead of time how many random numbers I'm going to need, so I can't generate random numbers in advance
cocreature 2017-02-09 06:05:56
novakboskov: what are the exact commands that you are using?
mmachenry1 2017-02-09 06:05:59
novakboskov: lpaste.net your code.
cocreature 2017-02-09 06:06:03
novakboskov: and where are you executing them?
eschnett 2017-02-09 06:06:54
lienz: yes, that's possible. to get it right is non-trivial. i'd look for a library or an algorithm for doing so (initializing the threads). i don't think that repa exposes an interface that allows you to access thread ids or so; repa assumes that each array element is calculated truly independently.
novakboskov 2017-02-09 06:07:39
mmachenry1: http://lpaste.net/352278 try3 and try4 do the same.
ph88_ 2017-02-09 06:08:05
does ghc have an option for profile-guided optimization ?
novakboskov 2017-02-09 06:08:55
cocreature: I'm using GHCi through Stack (wiht Haskell mode from Emacs) resolver: lts-7.19
ph88_ 2017-02-09 06:10:12
this looks very cool and haskell uses llvm too https://unhandledexpression.com/2016/04/14/using-llvm-pgo-in-rust/
lienz 2017-02-09 06:10:13
eschnett: ok thanks, I'll go searching in the hope of not having to write it myself
lienz 2017-02-09 06:10:44
I don't particularly mind if I have to use something other than repa, although I would rather avoid fiddling about with Vector to do multidimensional stuff (not that it is at all difficult, I just don't like it)
cocreature 2017-02-09 06:11:12
ph88_: afaik there is no such option
eschnett 2017-02-09 06:11:38
lienz: here's a pedestrian approach (essentially what you suggested): (1) create a small (20?) random number generators, (2) each rng creates a plain list of values, (3) you combine these to a repa array
mmachenry1 2017-02-09 06:15:09
novakboskov: I didn't get a stack overflow running your code.
mmachenry1 2017-02-09 06:15:25
I reduce it to just the try4 test case.
novakboskov 2017-02-09 06:17:59
mmachenry1: make that list a little bigger. try2 should make stack overflow, it is discussed in the article on wiki
novakboskov 2017-02-09 06:18:32
mmachenry1: try3 also should make stack overflow
alexv_ 2017-02-09 06:32:32
Is this family injective?
alexv_ 2017-02-09 06:32:42
-- | N-ary function from @n@ arguments of type @t@ to value of type @o@.
alexv_ 2017-02-09 06:32:47
type family NAry (n :: Nat) (t :: Type) (o :: Type) = (r :: Type) | r -> n t o where {
alexv_ 2017-02-09 06:32:53
NAry 1 t o = t -> o
alexv_ 2017-02-09 06:32:58
NAry n t o = t -> (NAry (n - 1) t o) }