packages feed

registry 0.1.3.5 → 0.1.3.6

raw patch · 3 files changed

+48/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

registry.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: cbbe4d160e44dac16179f493abbb7d0c83446f5ccd2bfe031502caf6091dd958+-- hash: e92b2f66ceff7a38e91de8e96c196577dec1046ec2f078503644b8bcb01419cb  name:           registry-version:        0.1.3.5+version:        0.1.3.6 synopsis:       data structure for assembling components description:    This library provides a "Registry" which is a data structure containing a list of functions and values representing dependencies in a directed acyclic graph. A `make` function can then be used to create a value of a specific type out of the registry.                 You can start with the [README](https://github.com/etorreborre/registry/blob/master/README.md) for a full description of the library.
src/Data/Registry/TH.hs view
@@ -189,11 +189,21 @@ typesOf (AppT (AppT PromotedConsT t) rest) = (typeName t, t) : typesOf rest typesOf _ = [] --- | Extract the name of a type, prettified up to 2 type constructors+-- | Extract the name of a type+--   There is a bit of massaging for tuple and arrow types for better display typeName :: Type -> String typeName (ConT n) = nameBase n-typeName (AppT (ConT t1) (ConT t2)) = nameBase t1 <> "[" <> nameBase t2 <> "]"-typeName (AppT (AppT (ConT t1) (ConT t2)) (ConT t3)) = nameBase t1 <> "[" <> nameBase t2 <> "[" <> nameBase t3 <> "]" <> "]"+typeName (AppT (AppT (TupleT 2) t1) t2) = "(" <> typeName t1 <> "," <> typeName t2 <> ")"+typeName (AppT (AppT (AppT (TupleT 3) t1) t2) t3) = "(" <> typeName t1 <> "," <> typeName t2 <> "," <> typeName t3 <> ")"+typeName (AppT (AppT (AppT (AppT (TupleT 4) t1) t2) t3) t4) = "(" <> typeName t1 <> "," <> typeName t2 <> "," <> typeName t3 <> "," <> typeName t4 <> ")"+typeName (AppT (TupleT i) t) = "Tuple" <> show i <> "(" <> typeName t <> ")"+typeName (AppT (AppT ArrowT t1) t2) = typeName t1 <> " -> " <> typeName t2+typeName (AppT (AppT (AppT ArrowT t1) t2) t3) = typeName t1 <> " -> " <> typeName t2 <> " -> " <> typeName t3+typeName (AppT (AppT (AppT (AppT ArrowT t1) t2) t3) t4) = typeName t1 <> " -> " <> typeName t2 <> " -> " <> typeName t3 <> " -> " <> typeName t4+typeName (AppT ArrowT t) = typeName t <> " -> "++typeName (AppT ListT t) = "[" <> typeName t <> "]"+typeName (AppT t1 t2) = typeName t1 <> "(" <> typeName t2 <> ")" typeName t = show t  -- | Return a deduplicated list of types from a list of types
test/Test/Data/Registry/SimpleExamples.hs view
@@ -106,3 +106,36 @@ -- | This version compiles but throws an exception at runtime dangerous :: Text1 dangerous = makeUnsafe @Text1 registry3++-- | Example with an optional configuration+--   The ProductionComponent will only be used if the ServiceConfig says we are in production+newtype ProductionComponent = ProductionComponent { doItInProduction :: IO () }+data ProductionConfig = ProductionConfig deriving (Eq, Show)++newtype Service = Service { service :: IO () }+data ServiceConfig = InProd | InDev deriving (Eq, Show)++-- | Production component definition++-- Normal constructor+newProductionComponent :: ProductionConfig -> Logging -> ProductionComponent+newProductionComponent _ _ = ProductionComponent (pure ())++-- Constructor which returns a "builder function", only used if a `ProductionConfig` is available+newProductionComponentBuilder :: Logging -> Tag "builder" (ProductionConfig -> ProductionComponent)+newProductionComponentBuilder = Tag . flip newProductionComponent++-- | Service component definition+--   It uses a builder for the ProductionComponent and only uses it in production+newService :: ServiceConfig -> Tag "builder" (ProductionConfig -> ProductionComponent) -> Service+newService InDev _ = Service { service = print ("dev" :: Text) }+newService InProd f = Service { service = doItInProduction ((unTag f) ProductionConfig)  }++registryWithOptionalComponents =+     val InDev+  +: fun newService+  +: fun newProductionComponentBuilder+  +: fun logging+  +: end++makeService = make @Service registryWithOptionalComponents