diff options
author | defanor <defanor@uberspace.net> | 2019-03-19 12:53:50 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2019-03-19 12:53:50 +0300 |
commit | b09a00426c4f72892f7863bbaaf688c21592dd03 (patch) | |
tree | 21ff48c0b0ba7543f583b2764d7cf833932c743d /Coalpit/Core.hs | |
parent | 0c64354f3d5d629e0bb5096ab91415c764517b1d (diff) |
Handle types with more than 3 constructors
Particularly ((a :+: b) :+: (c :+: d)) combinations.
Diffstat (limited to 'Coalpit/Core.hs')
-rw-r--r-- | Coalpit/Core.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Coalpit/Core.hs b/Coalpit/Core.hs index e166af9..f8e90be 100644 --- a/Coalpit/Core.hs +++ b/Coalpit/Core.hs @@ -233,6 +233,19 @@ instance (Constructor conA, Constructor conB, GCoalpit a, GCoalpit b) => in USum (handleRecCon nameA opt path (Proxy :: Proxy (a p))) (handleRecCon nameB opt path (Proxy :: Proxy (b p))) +instance {-# OVERLAPPABLE #-} + (GCoalpit a, GCoalpit b) => GCoalpit (a :+: b) where + gArgParser opt = + L1 <$> gArgParser opt + <|> + R1 <$> gArgParser opt + gToArgs opt (L1 x) = gToArgs opt x + gToArgs opt (R1 x) = gToArgs opt x + gArgHelper opt path (Proxy :: Proxy ((a :+: b) p)) = + -- let nameA = conName (undefined :: a p) + -- in + USum (gArgHelper opt path (Proxy :: Proxy (a p))) + (gArgHelper opt path (Proxy :: Proxy (b p))) -- Record Selectors |