You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've written some code making it possible to deriving Unifiable instances using Generic1 from GHC.Generics. How maintained is this repo, i.e. if I make a PR will it see the light of day on Hackage (modulo the code being acceptable of course)?
zipMatchViaGeneric
:: (Generic1t, GUnifiable (Rep1t))
=>ta->ta->Maybe (t (Eithera (a, a)))
zipMatchViaGeneric l r = to1 <$> gZipMatch (from1 l) (from1 r)
class (Traversablet, Generic1t) =>GUnifiabletwheregZipMatch::ta->ta->Maybe (t (Eithera (a,a)))
instanceGUnifiablet=>GUnifiable (M1mit) where
gZipMatch (M1 l) (M1 r) =M1<$> gZipMatch l r
instanceGUnifiableU1where
gZipMatch _ _ =JustU1instanceEqc=>GUnifiable (K1mc) where
gZipMatch (K1 l) (K1 r) | l == r =Just (K1 l)
|otherwise=NothinginstanceGUnifiablePar1where
gZipMatch (Par1 l) (Par1 r) =Just.Par1.Right$ (l, r)
instanceUnifiablex=>GUnifiable (Rec1x) where
gZipMatch (Rec1 l) (Rec1 r) =Rec1<$> zipMatch l r
instance (GUnifiablel, GUnifiabler) =>GUnifiable (l:+:r) where
gZipMatch (L1 l) (L1 r) =L1<$> gZipMatch l r
gZipMatch (R1 l) (R1 r) =R1<$> gZipMatch l r
gZipMatch _ _ =Nothinginstance (GUnifiablel, GUnifiabler) =>GUnifiable (l:*:r) where
gZipMatch (l1 :*: r1) (l2 :*: r2) =(:*:)<$> gZipMatch l1 l2 <*> gZipMatch r1 r2
instance (Unifiablea, GUnifiableb) =>GUnifiable (a:.:b) where
gZipMatch (Comp1 l) (Comp1 r) =do
x <- zipMatch l r >>=traverse
(\caseLeft a ->Just$Left<$> a
Right (a1, a2) -> gZipMatch a1 a2
)
pure (Comp1 x)
The text was updated successfully, but these errors were encountered:
I've written some code making it possible to deriving
Unifiable
instances usingGeneric1
fromGHC.Generics
. How maintained is this repo, i.e. if I make a PR will it see the light of day on Hackage (modulo the code being acceptable of course)?The text was updated successfully, but these errors were encountered: