446N/ADescription : folding functions for CSL terms and commands
446N/AMaintainer : Ewaryst.Schulz@dfki.de
6982N/Afolding functions for CSL terms and commands
446N/A { foldAss :: CMD -> OpDecl -> b -> a
446N/A , foldCmd :: CMD -> String -> [b] -> a
446N/A , foldSequence :: CMD -> [a] -> a
446N/A , foldCond :: CMD -> [(b, [a])] -> a
5073N/A , foldRepeat :: CMD -> b -> [a] -> a
446N/A , foldVar :: EXPRESSION -> Token -> b
446N/A , foldOp :: EXPRESSION -> OPID -> [EXTPARAM] -> [b] -> Range -> b
446N/A , foldList :: EXPRESSION -> [b] -> Range -> b
4744N/A , foldInterval :: EXPRESSION -> Double -> Double -> Range -> b
4744N/A , foldInt :: EXPRESSION -> APInt -> Range -> b
4744N/A , foldRat :: EXPRESSION -> APFloat -> Range -> b
4744N/A{- | Produces an error with given message on all entries. Use this if you
4744N/Aoverwrite only the EXPRESSION part and you do not use the CMD part anyway
4744N/AemptyRecord :: String -> Record a b
5073N/A-- | The identity transformation
4744N/AidRecord :: Record CMD EXPRESSION
4744N/A Record { foldAss = \ v _ _ -> v
4744N/A , foldRepeat = \ v _ _ -> v
4744N/A , foldOp = \ v _ _ _ _ -> v
4744N/A , foldInterval = \ v _ _ _ -> v
4744N/A{- | Passes the transformation through the CMD part and is the identity
4744N/ApassRecord :: Record CMD EXPRESSION
4744N/A idRecord { foldAss = const Ass
4744N/A , foldSequence = const Sequence
4744N/A , foldRepeat = const Repeat
4744N/A-- | Passes the transformation through both, the CMD and the EXPRESSION part
4744N/ApassAllRecord :: Record CMD EXPRESSION
4744N/A passRecord { foldVar = const Var
4744N/A , foldInterval = const Interval
4744N/A{- | Passes the transformation through the 'CMD' part by concatenating the
4744N/Aprocessed list from left to right and identity on expression part -}
4744N/AlistCMDRecord :: Record [a] EXPRESSION
4744N/A idRecord { foldAss = \ _ _ _ -> []
4744N/A , foldSequence = const concat
4744N/A , foldCond = \ _ -> concat . concatMap snd
4744N/A , foldRepeat = \ _ _ -> concat
4744N/A{- | Returns the first constant on the CMD part and the second
4744N/AconstRecord :: a -> b -> Record a b
4744N/A Record { foldAss = \ _ _ _ -> a
4744N/A , foldSequence = \ _ _ -> a
4744N/A , foldRepeat = \ _ _ _ -> a
4744N/A , foldOp = \ _ _ _ _ _ -> b
4744N/A , foldInterval = \ _ _ _ _ -> b
4744N/AfoldCMD :: Record a b -> CMD -> a
5073N/A Ass c def -> foldAss r f c $ foldTerm r def
4744N/A Cmd s l -> foldCmd r f s $ map (foldTerm r) l
5073N/A Sequence l -> foldSequence r f $ map (foldCMD r) l
4744N/A Cond l -> foldCond r f $ map cf l where
4744N/A cf (x, y) = (foldTerm r x, map (foldCMD r) y)
4744N/A Repeat c l -> foldRepeat r f (foldTerm r c) $ map (foldCMD r) l
4744N/AfoldTerm :: Record a b -> EXPRESSION -> b
4744N/A Op s epl al rg -> foldOp r t s epl (map (foldTerm r) al) rg
4744N/A List l rg -> foldList r t (map (foldTerm r) l) rg
4744N/A Interval from to rg -> foldInterval r t from to rg
4744N/A Int i rg -> foldInt r t i rg
4744N/A Rat f rg -> foldRat r t f rg