| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Registry.Internal.Types
Description
List of types used inside the Registry
Synopsis
- data Value
- data ValueDescription = ValueDescription {
- _valueType :: Text
- _valueValue :: Maybe Text
- describeValue :: (Typeable a, Show a) => a -> ValueDescription
- describeTypeableValue :: Typeable a => a -> ValueDescription
- showValue :: Value -> Text
- createValue :: (Typeable a, Show a) => a -> Value
- makeProvidedValue :: Dynamic -> ValueDescription -> Value
- makeCreatedValue :: Dynamic -> ValueDescription -> Dependencies -> Value
- createTypeableValue :: Typeable a => a -> Value
- createDynValue :: Dynamic -> Text -> Value
- valueDynTypeRep :: Value -> SomeTypeRep
- valueDyn :: Value -> Dynamic
- valDescription :: Value -> ValueDescription
- valDependencies :: Value -> Dependencies
- valDescriptionToText :: ValueDescription -> Text
- specializationContext :: Value -> Maybe Context
- usedSpecialization :: Value -> Maybe Specialization
- isInSpecializationContext :: SomeTypeRep -> Value -> Bool
- hasSpecializedDependencies :: Specializations -> Value -> Bool
- data Function = Function Dynamic FunctionDescription
- createFunction :: Typeable a => a -> Function
- data FunctionDescription = FunctionDescription {
- _inputTypes :: [Text]
- _outputType :: Text
- describeFunction :: Typeable a => a -> FunctionDescription
- showFunction :: Function -> Text
- funDescription :: Function -> FunctionDescription
- funDyn :: Function -> Dynamic
- funDynTypeRep :: Function -> SomeTypeRep
- funDescriptionToText :: FunctionDescription -> Text
- hasParameters :: Function -> Bool
- data Typed a
- newtype Functions = Functions [Function]
- describeFunctions :: Functions -> Text
- addFunction :: Function -> Functions -> Functions
- newtype Values = Values {}
- describeValues :: Values -> Text
- addValue :: Value -> Values -> Values
- newtype Context = Context {
- _contextStack :: [SomeTypeRep]
- newtype Dependencies = Dependencies {
- unDependencies :: [Value]
- newtype DependenciesTypes = DependenciesTypes {}
- dependenciesTypes :: Dependencies -> DependenciesTypes
- dependenciesOn :: Value -> Dependencies
- newtype Specializations = Specializations {}
- data Specialization = Specialization {}
- specializationStart :: Specialization -> SomeTypeRep
- specializationEnd :: Specialization -> SomeTypeRep
- specializationTargetType :: Specialization -> SomeTypeRep
- isContextApplicable :: Context -> Specialization -> Bool
- applicableTo :: Specializations -> Context -> Specializations
- specializedContext :: Context -> Specialization -> SpecializedContext
- data SpecializedContext = SpecializedContext {}
- createValueFromSpecialization :: Context -> Specialization -> Value
- describeSpecializations :: Specializations -> Text
- newtype Modifiers = Modifiers [(SomeTypeRep, Function)]
- describeModifiers :: Modifiers -> Text
Documentation
A Value is the Dynamic representation of a Haskell value + its description
It is either provided by the user of the Registry or created as part of the
resolution algorithm
If a Context is present for a a created value this means that this value
has been written as the result of a specialization. The first type of the
list of types in the context is the types under which the specialization must
apply and the other types are "parents" of the current value in the value
graph
data ValueDescription #
This registers the specific context in which a valu | Description of a value. It might just have a description for its type when it is a value created by the resolution algorithm
Constructors
| ValueDescription | |
Fields
| |
Instances
| Eq ValueDescription # | |
Defined in Data.Registry.Internal.Types Methods (==) :: ValueDescription -> ValueDescription -> Bool # (/=) :: ValueDescription -> ValueDescription -> Bool # | |
| Show ValueDescription # | |
Defined in Data.Registry.Internal.Types Methods showsPrec :: Int -> ValueDescription -> ShowS # show :: ValueDescription -> String # showList :: [ValueDescription] -> ShowS # | |
| Hashable ValueDescription # | |
Defined in Data.Registry.Internal.Types | |
describeValue :: (Typeable a, Show a) => a -> ValueDescription #
Describe a value with its type and actual content
describeTypeableValue :: Typeable a => a -> ValueDescription #
Describe a value with only its type
createValue :: (Typeable a, Show a) => a -> Value #
Create a Value from a Haskell value, using its Show instance for its description
makeProvidedValue :: Dynamic -> ValueDescription -> Value #
Make a ProvidedValue
makeCreatedValue :: Dynamic -> ValueDescription -> Dependencies -> Value #
make a CreatedValue in no particular context
createTypeableValue :: Typeable a => a -> Value #
Create a Value from a Haskell value, with only its Typeable description
createDynValue :: Dynamic -> Text -> Value #
Create a Value from a Dynamic value and some description
valueDynTypeRep :: Value -> SomeTypeRep #
Type representation of a Value
valDescription :: Value -> ValueDescription #
The description for a Value
valDependencies :: Value -> Dependencies #
The dependencies for a Value
specializationContext :: Value -> Maybe Context #
Return the creation context for a given value when it was created as the result of a "specialization"
usedSpecialization :: Value -> Maybe Specialization #
Return the specialization used to create a specific values
isInSpecializationContext :: SomeTypeRep -> Value -> Bool #
Return True if a type is part of the specialization context of a Value
hasSpecializedDependencies :: Specializations -> Value -> Bool #
Return True if a value has transitives dependencies which are specialized values
A Function is the Dynamic representation of a Haskell function + its description
Constructors
| Function Dynamic FunctionDescription |
createFunction :: Typeable a => a -> Function #
Create a Function value from a Haskell function
data FunctionDescription #
Description of a Function with input types and output type
Constructors
| FunctionDescription | |
Fields
| |
Instances
| Eq FunctionDescription # | |
Defined in Data.Registry.Internal.Types Methods (==) :: FunctionDescription -> FunctionDescription -> Bool # (/=) :: FunctionDescription -> FunctionDescription -> Bool # | |
| Show FunctionDescription # | |
Defined in Data.Registry.Internal.Types Methods showsPrec :: Int -> FunctionDescription -> ShowS # show :: FunctionDescription -> String # showList :: [FunctionDescription] -> ShowS # | |
describeFunction :: Typeable a => a -> FunctionDescription #
showFunction :: Function -> Text #
Show a Function as Text using its Description
funDescription :: Function -> FunctionDescription #
The Description of a Function
funDynTypeRep :: Function -> SomeTypeRep #
Type representation of a Function
hasParameters :: Function -> Bool #
Return True if a Function has some input parameters
A Typed value or function can be added to a Registry
It is either a value, having both Show and Typeable information
or a function having just Typeable information
Constructors
| TypedValue Value | |
| TypedFunction Function |
This is a list of functions (or "constructors") available for constructing values
describeFunctions :: Functions -> Text #
Display a list of constructors
addFunction :: Function -> Functions -> Functions #
Add one more Function to the list of Functions
List of values available which can be used as parameters to constructors for building other values
describeValues :: Values -> Text #
Display a list of values
The types of values that we are trying to build at a given moment of the resolution algorithm. IMPORTANT: this is a *stack*, the deepest elements in the value graph are first in the list
Constructors
| Context | |
Fields
| |
newtype Dependencies #
The values that a value depends on
Constructors
| Dependencies | |
Fields
| |
Instances
| Show Dependencies # | |
Defined in Data.Registry.Internal.Types Methods showsPrec :: Int -> Dependencies -> ShowS # show :: Dependencies -> String # showList :: [Dependencies] -> ShowS # | |
| Semigroup Dependencies # | |
Defined in Data.Registry.Internal.Types Methods (<>) :: Dependencies -> Dependencies -> Dependencies # sconcat :: NonEmpty Dependencies -> Dependencies # stimes :: Integral b => b -> Dependencies -> Dependencies # | |
| Monoid Dependencies # | |
Defined in Data.Registry.Internal.Types Methods mempty :: Dependencies # mappend :: Dependencies -> Dependencies -> Dependencies # mconcat :: [Dependencies] -> Dependencies # | |
| Hashable Dependencies # | |
Defined in Data.Registry.Internal.Types | |
newtype DependenciesTypes #
The values types that a value depends on
Constructors
| DependenciesTypes | |
Fields | |
Instances
| Eq DependenciesTypes # | |
Defined in Data.Registry.Internal.Types Methods (==) :: DependenciesTypes -> DependenciesTypes -> Bool # (/=) :: DependenciesTypes -> DependenciesTypes -> Bool # | |
| Show DependenciesTypes # | |
Defined in Data.Registry.Internal.Types Methods showsPrec :: Int -> DependenciesTypes -> ShowS # show :: DependenciesTypes -> String # showList :: [DependenciesTypes] -> ShowS # | |
| Semigroup DependenciesTypes # | |
Defined in Data.Registry.Internal.Types Methods (<>) :: DependenciesTypes -> DependenciesTypes -> DependenciesTypes # sconcat :: NonEmpty DependenciesTypes -> DependenciesTypes # stimes :: Integral b => b -> DependenciesTypes -> DependenciesTypes # | |
| Monoid DependenciesTypes # | |
Defined in Data.Registry.Internal.Types Methods mappend :: DependenciesTypes -> DependenciesTypes -> DependenciesTypes # mconcat :: [DependenciesTypes] -> DependenciesTypes # | |
dependenciesOn :: Value -> Dependencies #
The dependencies of a value + the value itself
newtype Specializations #
Specification of values which become available for construction when a corresponding type comes in context
Constructors
| Specializations | |
Fields | |
Instances
| Show Specializations # | |
Defined in Data.Registry.Internal.Types Methods showsPrec :: Int -> Specializations -> ShowS # show :: Specializations -> String # showList :: [Specializations] -> ShowS # | |
| Semigroup Specializations # | |
Defined in Data.Registry.Internal.Types Methods (<>) :: Specializations -> Specializations -> Specializations # sconcat :: NonEmpty Specializations -> Specializations # stimes :: Integral b => b -> Specializations -> Specializations # | |
| Monoid Specializations # | |
Defined in Data.Registry.Internal.Types Methods mappend :: Specializations -> Specializations -> Specializations # mconcat :: [Specializations] -> Specializations # | |
data Specialization #
A specialization is defined by
a path of types, from top to bottom in the
value graph and target value, which is the
value to use when we need a value on that type
on that path.
For example:
specializationPath = [App, PaymentEngine, TransactionRepository]
specializationValue = DatabaseConfig "localhost" 5432
This means that need to use this DatabaseConfig whenever
trying to find inputs needed to create a TransactionRepository
if that repository is necessary to create a PaymentEngine, itself
involved in the creation of the App
Constructors
| Specialization | |
Fields | |
Instances
| Show Specialization # | |
Defined in Data.Registry.Internal.Types Methods showsPrec :: Int -> Specialization -> ShowS # show :: Specialization -> String # showList :: [Specialization] -> ShowS # | |
specializationStart :: Specialization -> SomeTypeRep #
First type of a specialization
specializationEnd :: Specialization -> SomeTypeRep #
Last type of a specialization
specializationTargetType :: Specialization -> SomeTypeRep #
Return the type of the replaced value in a specialization
isContextApplicable :: Context -> Specialization -> Bool #
A specialization is applicable to a context if all its types are part of that context, in the right order
applicableTo :: Specializations -> Context -> Specializations #
Return the specifications valid in a given context
specializedContext :: Context -> Specialization -> SpecializedContext #
The depth of a specialization in a context is the
the index of the deepest type of that specialization
in the stack of types of that context
is the one having its "deepest" type (in the value graph)
the "deepest" in the current context
If there is a tie we take the "highest" highest type of each
data SpecializedContext #
For a given context this represents the position of a specialization path in that context. startRange is the index of the start type of the specialization endRange is the index of the last type.
Constructors
| SpecializedContext | |
Instances
createValueFromSpecialization :: Context -> Specialization -> Value #
Restrict a given context to the types of a specialization specializedContext :: Context -> Specialization -> Context specializedContext (Context cs) specialization = Context $ P.dropWhile (/= specializationEnd specialization) . dropWhileEnd (/= specializationStart specialization) $ cs
In a given context, create a value as specified by a specialization the full context is necessary since the specificationPath is only a subpath of a given creation context
describeSpecializations :: Specializations -> Text #
Display a list of specializations for the Registry, just showing the context (a type) in which a value must be selected
List of functions modifying some values right after they have been
built. This enables "tweaking" the creation process with slightly
different results. Here SomeTypeRep is the target value type a and
Constructors
| Modifiers [(SomeTypeRep, Function)] |
describeModifiers :: Modifiers -> Text #
Display a list of modifiers for the Registry, just showing the type of the modified value