The following combinators are available to create registries
| combinator | meaning |
|---|
end | the empty registry |
<: | append an element to the registry (a value, function or another registry) |
<+ | append an element to the registry (a value, function or another registry), but don't perform any check |
+: | append an element a to the registry, but do not check that the inputs of a can already be produced by the registry |
<+> | append 2 registries together |
| combinator | meaning |
val @a | a value of type a which can be added to the registry |
fun @f | a function of type f which can be added to the registry |
valTo @m @a | a value of type a which is added as m a to the registry |
funTo @m @f | a function of type i1 -> i2 -> ... -> o which is lifted into m i1 -> m i2 -> ... -> m o before being added to the registry |
It is also possible to only use val and fun and lift functions yourself with the following combinators:
| combinator | meaning |
allTo @m | lift a function of type i1 -> i2 -> ... -> o to m i1 -> m i2 -> ... -> m o |
argsTo @m | lift a function of type i1 -> i2 -> ... -> m o to m i1 -> m i2 -> ... -> m o |
outTo @m nat | lift a function of type i1 -> i2 -> ... -> n o to i1 -> i2 -> ... -> m o using nat :: forall x . n x -> m x |
| combinator | meaning |
|---|
make @a | build an element from a registry and throw an exception if it cannot be build |
makeEither @a | make a value and return Left <an error> if the value cannot be built |
makeSafe @a | check statically that an element can be build registry before making it |
The values which are "specialized" (see [#tweaking-the-registry]) can be built differently depending on the which other value we are trying to build:
- use the
make function to get the default value
- use the
makeSpecialized @a @b function to get a value of type b specialized in the context of building a
- use the
makeSpecializedPath @path @b function to get a value of type b specialized in the context of building a specific path of types in a data graph
| combinator | meaning |
normalize | make the list of types in the registry unique (no duplicated types) to speed-up compile times with make |
| combinator | meaning |
memoize @m @a | if a value of type m a is created, store the value a so that the same a is returned whenever m a is executed |
memoizeAll @m | run memoize for all the effectful output types of a registry |
specialize @a @b b | when trying to build a value of type a make sure that b is always used when a value of type b is required. b can either be a value created with val, or a function, created with fun (for example fun (\url port -> makeHttp url port)). Remember that values and functions can be lifted with valTo and funTo |
specializePath @[as] @b b | specialize a value but only for a given "path of types" when those types are part of the current search context |
tweak @a f | modify a value of type a with a function f :: a -> a right after it has been created and before storing it |
tweakUnspecialized @a f | modify a value of type a with a function f :: a -> a right after it has been created and before storing it, but only if it is not a specialized value |
When using the Rio monad to wire components for an application it can be necessary to ensure that some components
will only be created once before being used by other components.
In order to do this the following functions are available:
| function | meaning |
cacheAt :: Text -> Rio a -> Rio a | cache a Rio action for a given Text key |
singleton :: Rio a -> Rio a | make a component into a singleton so that there's only one instance in a components graph |
singletons :: Registry ins out -> Registry ins out | make singletons for all the Rio a out types of a registry, but only on unspecialized values |
| alias | meaning |
|---|
out :- a | Contains a out means that a is in the list of types out |