Generics and sums - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Asad Saeeduddin

Is there an easy way to get at the isomorphism between some type Either A (Either B (Either C ...)) and some type data Foo = X A | Y B | Z C | ...?

Asad Saeeduddin

perhaps using something built on top of GHC.Generics?

Sandy Maguire

maybe to . coerce . from

Sandy Maguire

well it'd work with the 2 case

Sandy Maguire

need to apply the froms and tos recursively

Asad Saeeduddin

@Sandy Maguire That doesn't seem to work. It complains it can't unify the representation of Either with that of the sum type

Asad Saeeduddin

the recursive part is what's giving me a hard time, I don't want to manually call to and coerce and so on repeatedly

Asad Saeeduddin

do any of the variant libraries provide isomorphisms with regular sum types?

Bolt

Oh that's a similar to my problem.. did you looked it up? Does a similar approach helps?

Sandy Maguire

check out generics-sop