registry-0.1.6.2: data structure for assembling components

Safe HaskellNone
LanguageHaskell2010

Data.Registry.Make

Contents

Description

This module provides functions to make values out of a registry. The general algorithm is the following

  1. for a given value type search in the existing list of values a value with the same type. If found return it
  2. if not found search a function having the desired output type if found, now try to recursively make all the input parameters. Keep a stack of the current types trying to be built.
  3. when trying to make an input parameter if the current input type is already in the types trying to be built then there is a cycle. Return an error in that case
  4. when a value has been constructed place it on top of the existing value list so that it can be reused by other functions
Synopsis

Documentation

make :: forall a ins out. (Typeable a, Contains a out, Solvable ins out) => Registry ins out -> a Source #

For a given registry make an element of type a We want to ensure that a is indeed one of the return types We also try to statically check if there aren't other possible errors

makeFast :: forall a ins out. (Typeable a, Contains a out) => Registry ins out -> a Source #

Same as make but without the solvable constraint to compile faster in tests for example

makeEither :: forall a ins out. Typeable a => Registry ins out -> Either Text a Source #

This version of make only execute checks at runtime this can speed-up compilation when writing tests or in ghci

makeUnsafe :: forall a ins out. Typeable a => Registry ins out -> a Source #

This version of make only execute checks at runtime this can speed-up compilation when writing tests or in ghci

SPECIALIZED VALUES

makeSpecialized :: forall a b ins out. (Typeable a, Typeable b, Contains b out, Solvable ins out) => Registry ins out -> b Source #

make for specialized values

makeSpecializedPath :: forall path b ins out. (PathToTypeReps path, Typeable b, Contains b out, Solvable ins out) => Registry ins out -> b Source #

make for specialized values

makeSpecializedFast :: forall a b ins out. (Typeable a, Typeable b, Contains b out) => Registry ins out -> b Source #

makeFast for specialized values

makeSpecializedPathFast :: forall path b ins out. (PathToTypeReps path, Typeable b, Contains b out) => Registry ins out -> b Source #

makeFast for specialized values

makeSpecializedUnsafe :: forall a b ins out. (Typeable a, Typeable b) => Registry ins out -> b Source #

makeUnsafe for specialized values

makeSpecializedPathUnsafe :: forall path b ins out. (PathToTypeReps path, Typeable b) => Registry ins out -> b Source #

makeUnsafe for specialized values

makeSpecializedEither :: forall a b ins out. (Typeable a, Typeable b) => Registry ins out -> Either Text b Source #

makeEither for specialized values

makeSpecializedPathEither :: forall path b ins out. (PathToTypeReps path, Typeable b) => Registry ins out -> Either Text b Source #

makeEither for specialized values

makeEitherWithContext :: forall a ins out. Typeable a => Context -> Registry ins out -> Either Text a Source #

This version of make only execute checks at runtime this can speed-up compilation when writing tests or in ghci