Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Control.Dependency
Description
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 :: (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 Methods 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 # (#.) :: Coercible c b => q b c -> Require identifier a b -> Require identifier a c # (.#) :: Coercible b a => Require identifier b c -> q a b -> Require identifier a c # | |
Functor (Require identifier content) Source # | |
Applicative (Require identifier content) Source # | |
Defined in Control.Dependency Methods 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 # | |
Alternative (Require identifier content) Source # | |
Defined in Control.Dependency |
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 #
Arguments
:: (result -> Bool) | predicate |
-> Require identifier content result | |
-> Require identifier content result |
Will drop the result unless the predicate is true.
computeRequire :: (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.
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 #