registry 0.3.3.2 → 0.3.3.3
raw patch · 3 files changed
+32/−5 lines, 3 files
Files
- registry.cabal +2/−2
- src/Data/Registry/Registry.hs +1/−1
- src/Data/Registry/Solver.hs +29/−2
registry.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: b4858fe4acf6e5d10d5b1ccbccf4ec9c5afefc6a5ed30c08bf688927144c6fbd+-- hash: 47e1b8cb4c02983874894c520912df6506645af95541522114123a894ce11395 name: registry-version: 0.3.3.2+version: 0.3.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
@@ -143,7 +143,7 @@ class AddRegistryLike a b c | a b -> c where (<:) :: a -> b -> c -instance (insr ~ (ins1 :++ ins2), outr ~ (out1 :++ out2), IsSubset ins1 (out1 :++ out2) ()) => AddRegistryLike (Registry ins1 out1) (Registry ins2 out2) (Registry insr outr) where+instance (insr ~ (ins1 :++ ins2), outr ~ (out1 :++ out2), AreSubset ins1 (out1 :++ out2) out1) => AddRegistryLike (Registry ins1 out1) (Registry ins2 out2) (Registry insr outr) where (<:) = (<+>) instance
src/Data/Registry/Solver.hs view
@@ -45,8 +45,26 @@ CanMake a (a ': _els) _t = () CanMake a (_b ': els) t = CanMake a els t --- | Compute if each element of a list of types is contained in--- another list+-- | Compute if a registry can be added to another registry+type family CanMakeMany (a :: Type) (els :: [Type]) (targets :: [Type]) :: Constraint where+ CanMakeMany a '[] ts =+ TypeError+ ( Text "The registry creating the output types "+ :$$: Text ""+ :$$: (Text " " :<>: ShowType ts)+ :$$: Text ""+ :$$: Text "cannot be added to the other registry because one input parameter"+ :$$: Text ""+ :$$: (Text " " :<>: ShowType (Output a))+ :$$: Text ""+ :$$: Text " is missing of the overall registry outputs"+ :$$: Text ""+ )+ CanMakeMany a (a ': _els) _ts = ()+ CanMakeMany a (_b ': els) ts = CanMakeMany a els ts++-- | Compute if each element of a list of types is contained in another list+-- when trying to add the function `target` class IsSubset (ins :: [Type]) (out :: [Type]) (target :: Type) instance IsSubset '[] out t@@ -55,6 +73,15 @@ -- a is also included in the set out. The search for a in out is done via a -- type family in order to be able to display an error message if it can't be found instance (CanMake a out t, IsSubset els out t) => IsSubset (a ': els) out t++-- | Compute if each element of a list of types is contained in+-- another list when trying to append 2 registries together+-- where `target` is the list of inputs of the first registry+class AreSubset (ins :: [Type]) (out :: [Type]) (targets :: [Type])++instance AreSubset '[] out ts++instance (CanMakeMany a out ts, AreSubset els out ts) => AreSubset (a ': els) out ts -- | Compute if each element of a list of types -- is the same as another in a different order