packages feed

getopt-generics 0.13.0.3 → 0.13.0.4

raw patch · 2 files changed

+22/−27 lines, 2 filesdep ~generics-sopPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: generics-sop

API changes (from Hackage documentation)

Files

getopt-generics.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.0.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: a8f8322b2416d58ac189c12c7f304a9e93419217f59a6b53375ab335009c9bc3+-- hash: 7569f6c1eafe060f3285fa68df5dfe8814e101dc3a65a5b63a5c95e6d274791a  name:           getopt-generics-version:        0.13.0.3+version:        0.13.0.4 synopsis:       Create command line interfaces with ease description:    Create command line interfaces with ease category:       Console, System@@ -63,7 +63,7 @@       base ==4.*     , base-compat >=0.8     , base-orphans-    , generics-sop >=0.1 && <0.5+    , generics-sop >=0.2.3 && <0.6     , tagged   default-language: Haskell2010 @@ -117,7 +117,7 @@     , base-compat >=0.8     , base-orphans     , filepath-    , generics-sop >=0.1 && <0.5+    , generics-sop >=0.2.3 && <0.6     , hspec >=2.1.8     , safe     , silently
src/WithCli/HasArguments.hs view
@@ -289,27 +289,22 @@   (GHC.Generic a, GTo a, GDatatypeInfo a, All2 HasArguments (GCode a)) =>   Modifiers ->   Result (Parser Unnormalized a)-genericParser modifiers = fmap (fmap gto) $ case gdatatypeInfo (Proxy :: Proxy a) of-  ADT _ typeName (constructorInfo :* Nil) ->-    case constructorInfo of-      (Record _ fields) ->-        fmap (fmap (SOP . Z)) (fieldsParser modifiers fields)-      Constructor{} ->-        fmap (fmap (SOP . Z)) (noSelectorsParser modifiers shape)-      Infix{} ->-        err typeName "infix constructors"-  ADT _ typeName Nil ->-    err typeName "empty data types"-  ADT _ typeName (_ :* _ :* _) ->-    err typeName "sum types"-  Newtype _ _ (Record _ fields) ->-    fmap (fmap (SOP . Z)) (fieldsParser modifiers fields)-  Newtype _ typeName (Constructor _) ->-    err typeName "constructors without field labels"-  where-    err typeName message = Errors $-      "getopt-generics doesn't support " ++ message ++-      " (" ++ typeName ++ ")."+genericParser modifiers = fmap (fmap gto) $+  let datatypeInfo = gdatatypeInfo (Proxy :: Proxy a)+      err :: forall a . String -> Result a+      err message = Errors $+        "getopt-generics doesn't support " ++ message +++        " (" ++ datatypeName datatypeInfo ++ ")."+  in case constructorInfo datatypeInfo of+    firstConstructor :* Nil ->+      case firstConstructor of+        Record _ fields ->+          fmap (fmap (SOP . Z)) (fieldsParser modifiers fields)+        Constructor{} ->+          fmap (fmap (SOP . Z)) (noSelectorsParser modifiers shape)+        Infix{} -> err "infix constructors"+    Nil -> err "empty data types"+    _ :* _ :* _ -> err "sum types"  fieldsParser :: All HasArguments xs =>   Modifiers -> NP FieldInfo xs -> Result (Parser Unnormalized (NP I xs))@@ -323,6 +318,6 @@   Modifiers -> Shape xs -> Result (Parser Unnormalized (NP I xs)) noSelectorsParser modifiers = \ case   ShapeNil -> return $ emptyParser Nil-  ShapeCons rest -> +  ShapeCons rest ->     fmap (fmap (\ (a, r) -> a :* r)) $       combine (fmap (fmap I) $ (argumentsParser modifiers Nothing)) (noSelectorsParser modifiers rest)