Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
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 | ...?
Either A (Either B (Either C ...))
data Foo = X A | Y B | Z C | ...
perhaps using something built on top of GHC.Generics?
GHC.Generics
maybe to . coerce . from
to . coerce . from
well it'd work with the 2 case
need to apply the froms and tos recursively
from
to
@Sandy Maguire That doesn't seem to work. It complains it can't unify the representation of Either with that of the sum type
Either
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
coerce
do any of the variant libraries provide isomorphisms with regular sum types?
Oh that's a similar to my problem.. did you looked it up? Does a similar approach helps?
check out generics-sop
Is there an easy way to get at the isomorphism between some type
Either A (Either B (Either C ...))
and some typedata Foo = X A | Y B | Z C | ...
?perhaps using something built on top of
GHC.Generics
?maybe
to . coerce . from
well it'd work with the 2 case
need to apply the
from
s andto
s recursively@Sandy Maguire That doesn't seem to work. It complains it can't unify the representation of
Either
with that of the sum typethe recursive part is what's giving me a hard time, I don't want to manually call
to
andcoerce
and so on repeatedlydo any of the variant libraries provide isomorphisms with regular sum types?
Oh that's a similar to my problem.. did you looked it up? Does a similar approach helps?
check out generics-sop