jvliwanag 2017-02-19 18:52:00
guys, is there a generic way of flattening out a tuple with arbitrary lengths? meaning: (((a, b), c), d) -> (a, b, c, d) and the other way around
jchia 2017-02-19 18:59:20
jvliwanag: The only way I can think of is TH.
jchia 2017-02-19 19:00:22
jvliwanag: Or maybe type classes can help let me se
jchia 2017-02-19 19:02:02
jvliwanag: (((a, a), a), a) -> [a] maybe be doable without TH but I don't know about your original question.
pacak 2017-02-19 19:14:55
jvliwanag: You can try ghc generics
maybefbi 2017-02-19 19:15:47
how hard is the standard chartered interview?
jvliwanag 2017-02-19 19:20:34
yeah jchia, I'd need the original types. pacak - any useful resources for ghc generics? been looking at the hlist stuff as well
osa1 2017-02-19 19:22:40
I wish we had a search bar in Haddock pages for searching for a definition in a library
osa1 2017-02-19 19:23:21
currently the closest thing is to go to the index page, list "all", and C-f
pacak 2017-02-19 19:23:37
jvliwanag: I don't think there are any good tutorials that are up to date, but the idea is to represent datatypes as sums and products of size 2 and all you need is to write a function that operates on those sums and products
pacak 2017-02-19 19:24:42
It also provides typeclasses that allow you to extract things like constructor names or field accessors
pacak 2017-02-19 19:25:07
On small datatypes ghc can generate nice code
pacak 2017-02-19 19:25:38
But compilation cost is quadratic or more
erlandsona 2017-02-19 19:26:32
quit
jvliwanag 2017-02-19 19:29:12
pacak: nice. i've been using shapeless as well on scala which drew inspiration form syb i believe. I hope ghc generics will be similar
jvliwanag 2017-02-19 19:29:39
i've seen generics-sop as well though. i wonder how that compares