Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module is a glorified wrapper over lookup
. It
let you define computations in an applicative way that "require" some
optional values, defined by an identifier.
Once defined, it is possible to extract the list of identifiers, and also to evaluate the computation.
let computation = ( (+) <$> require "a" <*> require "b" ) > computeRequire M.empty computation :: Maybe Int Nothing > computeRequire (M.fromList [("a", 12), ("b", 15)]) computation :: Maybe Int Just 27 > computeRequire (M.fromList [("a", 12), ("c", 15)]) computation :: Maybe Int Nothing
Synopsis
- data Require identifier content a
- require :: Eq identifier => identifier -> Require identifier content content
- requireFilter :: (identifier -> Bool) -> Require identifier content (identifier, content)
- guardResult :: (result -> Bool) -> Require identifier content result -> Require identifier content result
- computeRequire :: forall identifier content f a. (Ord identifier, Eq identifier, Monad f, Alternative f) => [(identifier, content)] -> Require identifier content a -> f a
- computeRequireIntermediate :: forall identifier content f a. (Ord identifier, Eq identifier, Monad f, Alternative f) => [(identifier, content)] -> Require identifier content a -> f a
- isComputable :: (Ord identifier, Eq identifier) => Set identifier -> Require identifier content a -> Bool
- triggersAnalyzer :: identifier -> Require identifier content a -> Bool
Documentation
data Require identifier content a Source #
The main data type, used to model a computation that requires a list of named parameters (the "identifier"), that are linked to a "content", and that will yield a result of type "a".
Instances
Profunctor (Require identifier) Source # | |
Defined in Control.Dependency dimap :: (a -> b) -> (c -> d) -> Require identifier b c -> Require identifier a d # lmap :: (a -> b) -> Require identifier b c -> Require identifier a c # rmap :: (b -> c) -> Require identifier a b -> Require identifier a c # (#.) :: forall a b c q. Coercible c b => q b c -> Require identifier a b -> Require identifier a c # (.#) :: forall a b c q. Coercible b a => Require identifier b c -> q a b -> Require identifier a c # | |
Alternative (Require identifier content) Source # | |
Defined in Control.Dependency | |
Applicative (Require identifier content) Source # | |
Defined in Control.Dependency pure :: a -> Require identifier content a # (<*>) :: Require identifier content (a -> b) -> Require identifier content a -> Require identifier content b # liftA2 :: (a -> b -> c) -> Require identifier content a -> Require identifier content b -> Require identifier content c # (*>) :: Require identifier content a -> Require identifier content b -> Require identifier content b # (<*) :: Require identifier content a -> Require identifier content b -> Require identifier content a # | |
Functor (Require identifier content) Source # | |
require :: Eq identifier => identifier -> Require identifier content content Source #
This operator let you "require" a value in a computation.
requireFilter :: (identifier -> Bool) -> Require identifier content (identifier, content) Source #
:: (result -> Bool) | predicate |
-> Require identifier content result | |
-> Require identifier content result |
Will drop the result unless the predicate is true.
computeRequire :: forall identifier content f a. (Ord identifier, Eq identifier, Monad f, Alternative f) => [(identifier, content)] -> Require identifier content a -> f a Source #
Evaluate a computation, given a map of key/values for possible parameters.
computeRequireIntermediate :: forall identifier content f a. (Ord identifier, Eq identifier, Monad f, Alternative f) => [(identifier, content)] -> Require identifier content a -> f a Source #
Evaluate a computation, given a map of key/values for possible parameters. Returns an empty result when alternatives are present and the first choice failed.
isComputable :: (Ord identifier, Eq identifier) => Set identifier -> Require identifier content a -> Bool Source #
Checks if a computation can be completed given a set of known identifiers.
triggersAnalyzer :: identifier -> Require identifier content a -> Bool Source #