summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretorreborre <>2019-06-11 06:09:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-06-11 06:09:00 (GMT)
commitc0379d2ca4b14c87e66f7b2286050720612ed442 (patch)
tree27da06491428070ffda98e04ad5f3a2d7c5470cd
parent659f52c61cd3f43f8a868235ffb1744cf2c28f2b (diff)
version 0.1.6.10.1.6.1
-rw-r--r--registry.cabal4
-rw-r--r--src/Data/Registry/State.hs11
2 files changed, 13 insertions, 2 deletions
diff --git a/registry.cabal b/registry.cabal
index 09b3d61..48ac7fd 100644
--- a/registry.cabal
+++ b/registry.cabal
@@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
--- hash: 9d1d96e730c89433825e01a4a94a2efa05f6d8ae2d3de62e5357c26e04c73dd9
+-- hash: b2a9bd3b890c2e666f472cab045fa0e78cb9e7663a6fbbac1a2417d264d3b534
name: registry
-version: 0.1.6.0
+version: 0.1.6.1
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.
diff --git a/src/Data/Registry/State.hs b/src/Data/Registry/State.hs
index 121780f..ab7955a 100644
--- a/src/Data/Registry/State.hs
+++ b/src/Data/Registry/State.hs
@@ -57,6 +57,10 @@ addToRegistry (TypedValue v) (Registry (Values vs) functions specializations mod
addToRegistry (TypedFunction f) (Registry (Values vs) (Functions fs) specializations modifiers) =
Registry (Values vs) (Functions (f : fs)) specializations modifiers
+-- | Concatenate a registry to another statefully (to be used with $(makeGenerators ''MyType))
+concatUnsafeS :: (MonadState (Registry ins out) m) => Registry ins' out' -> m ()
+concatUnsafeS r = modify (concatRegistryUnsafe r)
+
-- | Register modifications of the registry without changing its type
addToRegistryUnsafe :: (Typeable a) => Typed a -> Registry ins out -> Registry ins out
addToRegistryUnsafe (TypedValue v) (Registry (Values vs) functions specializations modifiers) =
@@ -64,3 +68,10 @@ addToRegistryUnsafe (TypedValue v) (Registry (Values vs) functions specializatio
addToRegistryUnsafe (TypedFunction f) (Registry (Values vs) (Functions fs) specializations modifiers) =
Registry (Values vs) (Functions (f : fs)) specializations modifiers
+
+-- | Concatenate 2 registries
+concatRegistryUnsafe :: Registry ins out -> Registry ins' out' -> Registry ins' out'
+concatRegistryUnsafe
+ (Registry (Values vs1) (Functions fs1) (Specializations ss1) (Modifiers ms1))
+ (Registry (Values vs2) (Functions fs2) (Specializations ss2) (Modifiers ms2)) =
+ Registry (Values (vs1 <> vs2)) (Functions (fs1 <> fs2)) (Specializations (ss1 <> ss2)) (Modifiers (ms1 <> ms2))