ekmett / pointed

pointed and copointed data
Other
23 stars 9 forks source link

Instances for GHC.Generics #18

Closed conal closed 6 years ago

conal commented 8 years ago

Instance of Pointed and Copointed for the types in GHC.Generics would be handy. I'm unsure what all of them would be, including Pointed (f :+: g), Copointed (f :+: g), and Copointed (f :*: g).

Here are a few instances:

instance Pointed Par1 where
  point = Par1

instance (Pointed f, Pointed g) => Pointed (f :*: g) where
  point a = point a :*: point a

instance (Pointed f, Pointed g) => Pointed (g :.: f) where
  point = Comp1 . point . point

instance Copointed Par1 where
  copoint = unPar1

instance (Copointed f, Copointed g) => Copointed (g :.: f) where
  copoint = copoint . copoint . unComp1

I could whip up some more and submit a pull request.