r/purescript • u/tuxkimo • Mar 07 '16
Downsides of purescript-generics?
I found purescript-generics so much more approachable than Haskell generics. I got started immediately, I am still struggling with Haskell generics. I wonder if there are any downsides or if purescript generics are simply better in all regards?
5
Upvotes
2
u/tuxkimo Mar 08 '16
I believe I found a drawback: https://github.com/purescript-contrib/purescript-argonaut-codecs/issues/13
In my current understanding of purescript-generics, implementing aeson's behaviour, respecting type class instances, would be really hard. I would love to be proven wrong!
1
u/tuxkimo Mar 08 '16
Thank you, this was really enlightening :-)
4
u/sclv Mar 08 '16
The lack of sophisticated typeclass machinery means that we can't alter function types based on the structure of the data we are generic over. We're reflecting only on the value level, and not the type level.
On the other hand, I think this is to me a purely theoretical benefit of Haskell generics, as I haven't seen any Haskell code that makes use of this functionality. (counterexamples welcome!)
You may find generics-sop (https://hackage.haskell.org/package/generics-sop) more accessible than the builtin GHC.Generics. I took a lot of inspiration from it.
1
u/paf31 Mar 07 '16
From an API point of view, I find PS's generics much simpler. I think /u/sclv did a great job with the
purescript-genericsrewrite. I don't know if they're better "in all regards". A performance comparison (relative to non-generic code in the same language) would be interesting, for example. I suspect we'd lose badly because of a lack of compiler optimizations.