packages feed

registry 0.1.5.4 → 0.1.5.5

raw patch · 2 files changed

+58/−2 lines, 2 files

Files

registry.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 9e2d0caa23638b41617eafc4a05fd7c6763cfdc80dbd3361592d5786faea1994+-- hash: 11d110cf6c7454893e5841b49f0b4c472673b9ca74f0cd2f90183bc3b9aaf379  name:           registry-version:        0.1.5.4+version:        0.1.5.5 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/State.hs view
@@ -17,22 +17,78 @@ addFunTo :: forall m a b ins out . (ApplyVariadic m a b, Typeable a, Typeable b, IsSubset (Inputs b) ins, Contains (Output b) out) => a -> Registry ins out -> Registry ins out addFunTo = modifyRegistry @b . funTo @m +-- | Add an element to the registry without changing its type+--   *** This possibly adds untracked output type! ***+addFunTo' :: forall m a b ins out . (ApplyVariadic m a b, Typeable a, Typeable b, IsSubset (Inputs b) ins) => a -> Registry ins out -> Registry ins out+addFunTo' = modifyRegistry' @b . funTo @m++-- | Add an element to the registry without changing its type+--   *** This possibly adds untracked input types / output type! ***+addFunToUnsafe :: forall m a b ins out . (ApplyVariadic m a b, Typeable a, Typeable b) => a -> Registry ins out -> Registry ins out+addFunToUnsafe = modifyRegistryUnsafe @b . funTo @m+ -- | Add an element to the registry without changing its type, in the State monad addFunS :: (Typeable a, IsSubset (Inputs a) ins, Contains (Output a) out, MonadState (Registry ins out) m) => a -> m () addFunS = modify . addFun  -- | Add an element to the registry without changing its type, in the State monad+--   *** This possibly adds untracked output type! ***+addFunS' :: (Typeable a, IsSubset (Inputs a) ins, MonadState (Registry ins out) m) => a -> m ()+addFunS' = modify . addFun'++-- | Add an element to the registry without changing its type, in the State monad+--   *** This possibly adds untracked input types / output type! ***+addFunUnsafeS :: (Typeable a, MonadState (Registry ins out) m) => a -> m ()+addFunUnsafeS = modify . addFunUnsafe++-- | Add an element to the registry without changing its type, in the State monad addToS :: forall n a b m ins out . (ApplyVariadic n a b, Typeable a, Typeable b, Typeable a, IsSubset (Inputs b) ins, Contains (Output b) out, MonadState (Registry ins out) m) => a -> m () addToS = modify . addFunTo @n @a @b +-- | Add an element to the registry without changing its type, in the State monad+--   *** This possibly adds untracked output type! ***+addToS' :: forall n a b m ins out . (ApplyVariadic n a b, Typeable a, Typeable b, Typeable a, IsSubset (Inputs b) ins, MonadState (Registry ins out) m) => a -> m ()+addToS' = modify . addFunTo' @n @a @b++-- | Add an element to the registry without changing its type, in the State monad+--   *** This possibly adds untracked input types / output type! ***+addToUnsafeS :: forall n a b m ins out . (ApplyVariadic n a b, Typeable a, Typeable b, Typeable a, MonadState (Registry ins out) m) => a -> m ()+addToUnsafeS = modify . addFunToUnsafe @n @a @b+ -- | Add an element to the registry without changing its type addFun :: (Typeable a, IsSubset (Inputs a) ins, Contains (Output a) out) => a -> Registry ins out -> Registry ins out addFun = modifyRegistry . fun +-- | Add an element to the registry without changing its type+--   *** This possibly adds untracked output type! ***+addFun' :: (Typeable a, IsSubset (Inputs a) ins) => a -> Registry ins out -> Registry ins out+addFun' = modifyRegistry' . fun++-- | Add an element to the registry without changing its type+--   *** This possibly adds untracked input types / output type! ***+addFunUnsafe :: (Typeable a) => a -> Registry ins out -> Registry ins out+addFunUnsafe = modifyRegistryUnsafe . fun+ -- | Register modifications of elements which types are already in the registry modifyRegistry :: (Typeable a, IsSubset (Inputs a) ins, Contains (Output a) out) => Typed a -> Registry ins out -> Registry ins out modifyRegistry (TypedValue v) (Registry (Values vs) functions specializations modifiers) =   Registry (Values (v : vs)) functions specializations modifiers  modifyRegistry (TypedFunction f) (Registry (Values vs) (Functions fs) specializations modifiers) =+  Registry (Values vs) (Functions (f : fs)) specializations modifiers++-- | Register modifications of elements for which only the input types are in the registry+modifyRegistry' :: (Typeable a, IsSubset (Inputs a) ins) => Typed a -> Registry ins out -> Registry ins out+modifyRegistry' (TypedValue v) (Registry (Values vs) functions specializations modifiers) =+  Registry (Values (v : vs)) functions specializations modifiers++modifyRegistry' (TypedFunction f) (Registry (Values vs) (Functions fs) specializations modifiers) =+  Registry (Values vs) (Functions (f : fs)) specializations modifiers++-- | Register modifications of the registry without changing its type+modifyRegistryUnsafe :: (Typeable a) => Typed a -> Registry ins out -> Registry ins out+modifyRegistryUnsafe (TypedValue v) (Registry (Values vs) functions specializations modifiers) =+  Registry (Values (v : vs)) functions specializations modifiers++modifyRegistryUnsafe (TypedFunction f) (Registry (Values vs) (Functions fs) specializations modifiers) =   Registry (Values vs) (Functions (f : fs)) specializations modifiers