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 | |
parent | 0c64354f3d5d629e0bb5096ab91415c764517b1d (diff) |
Handle types with more than 3 constructors
Particularly ((a :+: b) :+: (c :+: d)) combinations.
-rw-r--r-- | Coalpit/Core.hs | 13 | ||||
-rw-r--r-- | coalpit.cabal | 2 |
2 files changed, 14 insertions, 1 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 diff --git a/coalpit.cabal b/coalpit.cabal index e3248a1..4a6462a 100644 --- a/coalpit.cabal +++ b/coalpit.cabal @@ -1,5 +1,5 @@ name: coalpit -version: 0.1.1.0 +version: 0.1.1.1 synopsis: Command-line options and DSV parsing and printing description: This library generates parsers and printers for given data types, in the form of command-line |