Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Control.Applicative
- data C = C
- data T = T
- data P = P
- data N = N deriving Eq
- data S = S
- data S' = S'
- getParameterValuestoSeq :: C -> [T]
- getParameterValuestoSeq = undefined
- getParameter :: T -> P
- getParameter = undefined
- getVariableName :: P -> N
- getVariableName = undefined
- getValue :: T -> S'
- getValue = undefined
- option :: S' -> Maybe S
- option = undefined
- getDefaultValue :: P -> S
- getDefaultValue = undefined
- headOption :: [x] -> Maybe x
- headOption = undefined -- listToMaybe
- getOrElse :: x -> Maybe x -> x
- getOrElse = undefined -- fromMaybe
- f :: C -> N -> Maybe S
- f scenario name = headOption . fmap (\t -> getDefaultValue (getParameter t) `getOrElse` option (getValue t)) $ filter (\t -> getVariableName (getParameter t) == name) (getParameterValuestoSeq scenario)
- f' :: C -> N -> Maybe S
- f' scenario name =
- let z = headOption $ filter (\t -> getVariableName (getParameter t) == name) (getParameterValuestoSeq scenario)
- in fmap ((getOrElse . getDefaultValue . getParameter) <*> (option . getValue)) z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement