registry 0.1.3.2 → 0.1.3.3
raw patch · 5 files changed
+30/−15 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Data.Registry.Registry: normalize :: Registry ins out -> Registry (Normalized ins) (Normalized out)
- Data.Registry.Solver: type family (:++) (x :: [k]) (y :: [k]) :: [k]
+ Data.Registry.Solver: type family Normalized (as :: [*]) :: [*]
Files
- registry.cabal +2/−2
- src/Data/Registry/Registry.hs +5/−0
- src/Data/Registry/Solver.hs +18/−6
- test/Test/Data/Registry/GenSpec.hs +1/−1
- test/Test/Data/Registry/SimpleExamples.hs +4/−6
registry.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 5182f329ceb763878b463e07c0dba6c9691d5aba4925e9cd654317d86f7bf78f+-- hash: ec8e2e4a28f9cfa59677d96e775326fb0b0e7bde8cbbc47719ff01cbdb5fecdc name: registry-version: 0.1.3.2+version: 0.1.3.3 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/Registry.hs view
@@ -103,6 +103,11 @@ (+:) :: (Typeable a) => Typed a -> Registry ins out -> Registry (Inputs a :++ ins) (Output a ': out) (+:) = register +-- | Make the lists of types in the Registry unique, either for better display+-- or for faster compile-time resolution with the make function+normalize :: Registry ins out -> Registry (Normalized ins) (Normalized out)+normalize (Registry vs fs ss ms) = Registry vs fs ss ms+ -- | The empty Registry end :: Registry '[] '[] end = Registry (Values []) (Functions []) (Specializations []) (Modifiers [])
src/Data/Registry/Solver.hs view
@@ -1,8 +1,9 @@-{-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE PolyKinds #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-} {- | Type level functions to statically assess@@ -28,7 +29,7 @@ -- | Compute if a type is contained in a list of types type family Contains (a :: *) (els :: [*]) :: Constraint where- Contains a '[] = TypeError ('Text "No element of type " ':<>: 'ShowType a ':<>: 'Text " can be built out of the registry")+ Contains a '[] = TypeError (Text "No element of type " ':<>: 'ShowType a ':<>: 'Text " can be built out of the registry") Contains a (a ': els) = () Contains a (b ': els) = Contains a els @@ -54,3 +55,14 @@ type family (:++) (x :: [k]) (y :: [k]) :: [k] where '[] :++ xs = xs (x ': xs) :++ ys = x ': (xs :++ ys)++-- | Return '[a] only if it is not already in the list of types+type family FindUnique (a :: *) (as :: [*]) :: [*] where+ FindUnique a '[] = '[a]+ FindUnique a (a ': rest) = '[]+ FindUnique a (b ': rest) = FindUnique a rest++type family Normalized (as :: [*]) :: [*] where+ Normalized '[] = '[]+ Normalized '[a] = '[a]+ Normalized (a ': rest) = FindUnique a rest :++ Normalized rest
test/Test/Data/Registry/GenSpec.hs view
@@ -98,7 +98,7 @@ -- * WITH VARIANTS registry' =- fun (sequence . replicate @(Gen Salary) 10)+ fun (sequence . replicate @(Gen Salary) 100) +: fun salaryGen +: funTo @Gen (tag @"Fixed" Fixed) +: funTo @Gen (tag @"Variable" Variable)
test/Test/Data/Registry/SimpleExamples.hs view
@@ -40,9 +40,8 @@ toText2 :: Text1 -> Text2 toText2 (Text1 t) = Text2 t -registry1 :: Registry (Inputs Int :++ '[Int, Int, Text, Text1])- '[Output Int, Text, Text1, Text2]-registry1 =+registry1 :: Registry [Int, Text, Text1] [Int, Text, Text1, Text2]+registry1 = normalize $ val int1 +: fun add1 +: fun add2@@ -67,7 +66,7 @@ countSize1 :: Text -> Int1 countSize1 t = Int1 (T.length t) -registry2 :: Registry (Inputs Int :++ '[Int, Text]) '[Output Int, Text, Int1]+registry2 :: Registry '[Int, Text] '[Int, Text, Int1] registry2 = fun int1 +: fun add1@@ -89,8 +88,7 @@ unknown :: Double -> Text1 unknown _ = Text1 "text1" -registry3 :: Registry (Inputs Int :++ '[Double, Int, Text])- '[Output Int, Text1, Text, Int1]+registry3 :: Registry [Double, Int, Text] [Int, Text1, Text, Int1] registry3 = val int1 +: fun unknown