head :: [a] -> aLast element of the list

last :: [a] -> aAll elements except the first one

tail :: [a] -> [a]All elements except the last one

init :: [a] -> [a]Length of a list

length :: [a] -> Int

Conversion from list to setinstanceEq [a] => Eq {a}whereSet xs == Set ys = (xs == ys)instanceOrd [a] => Ord {a} ...

mkSet :: Ord a => [a] -> {a}Map function for sets

setmap :: Ord b => (a -> b) -> {a} -> {b} setmap f xs = { f(x) | x <-: xs }Combining sets

union :: Ord a => {a} -> {a} -> {a} bigUnion :: Ord a => {{a}} -> {a} intersect :: Ord a => {a} -> {a} -> {a} difference :: Ord a => {a} -> {a} -> {a}Test for empty set

empty :: {a} -> BoolDetermine cardinality of a set

card :: {a} -> IntGet one arbitrary element of a set. The function can only be applied to non empty sets.

one :: {a} -> aFold on non empty sets

fold1 :: (a -> a -> a) -> {a} -> aConvertion from set to list

expr2list :: {a} -> [a]

infixl 0 :=Skip rule

skip :: Rule ()Firing rules

fire1 :: Rule () -> IO () fire :: Int -> Rule () -> IO () fireWhile :: Bool -> Rule () -> IO () fireUntil :: Bool -> Rule () -> IO () fixpoint :: Rule () -> IO ()Putting trace information in a rule. The first parameter is the trace action.

trace :: IO () -> Rule () -> Rule ()Creating dynamic functions

initVal :: (Eq a, AsmTerm a) => String -> a -> Dynamic a initValStdin :: String -> Dynamic String initValStdout :: Bool -> String -> Dynamic String initAssocs :: (AsmTerm key, AsmTerm val, AsmOrd key, Eq val) => String -> [(key,val)] -> Dynamic (key -> val)Predefined dynamic functions

stdout :: Dynamic String stdout = initValStdout False "stdout" stdin :: Dynamic String stdin = initValStdin "stdin"Accessing information stored in dynamic functions

assocs :: Dynamic (key -> val) -> [(key,val)] assocs = primAsmAssocs dom :: Dynamic (key -> val) -> {key} dom = mkSet . map fst . assocs ran :: Dynamic (key -> val) -> {val} ran = mkSet . map snd . assocs inDom :: key -> Dynamic (key -> val) -> Bool inDom = primAsmInDom notInDom :: key -> Dynamic (key -> val) -> Bool notInDom key fun = not(key `inDom` fun)Datatypes and instances

dataRule a = Skip | Rule ...instanceFunctor Rulewheremap f (Rule m) = Rule (map f m) map f Skip = SkipinstanceMonad Rulewhereresult = Rule . result Rule m `bind` f = Rule (m `bind` (\x ->letRule r = f xinr)) Skip `bind` f = f (error "skip does not return a value")instanceMonad0 Rulewherezero = SkipinstanceMonadPlus Rulewherea ++ b =doa; bclassAsmOrd awhereasmCompare :: a -> a -> IntclassAsmTerm awhere(:=) :: Dynamic a -> a -> Rule () asmDefault :: a asmDefault = primAsmDefault ()instanceAsmTerm BoolwhereasmDefault = FalseinstanceAsmTerm IntinstanceAsmTerm FloatinstanceAsmTerm CharinstanceAsmTerm StringinstanceAsmTerm a => AsmTerm [a]instance(AsmTerm a, AsmTerm b) => AsmTerm (a,b)instance(AsmTerm a, AsmTerm b, AsmTerm c) => AsmTerm (a,b, c)instance(AsmTerm a, AsmTerm b, AsmTerm c, AsmTerm d) => AsmTerm (a,b, c, d)instanceAsmTerm a => Eq awhere(==) = genericEqinstanceAsmTerm a => AsmOrd awhereasmCompare = genericCmp

seq :: Rule () -> Rule () -> Rule ()The rule

Iteration of a rule until a fixpoint is reached (no further updates)

iterate :: Rule () -> Rule ()There are some nice features

`iterate skip`is equivalent to`skip``iterate (`behaves like the normal while loop.**if**cond**then**r**else**skip`iterate (x := 1)`is a never ending computation (update set is always non-empty).

agents :: Dynamic (Agent -> Bool)Randomly choosing one rule to fire.

multi :: Dynamic (a -> (a -> Rule ())) -> Rule ()Let

The expression

- agents
- assocs
- bigUnion
- card
- difference
- dom
- empty
- expr2list
- fire
- fire1
- fireUntil
- fireWhile
- fixpoint
- fold1
- head
- init
- initAssocs
- initVal
- initValStdin
- initValStdout
- intersect
- inDom
- iterate
- last
- length
- multi
- notInDom
- one
- ran
- seq
- skip
- stdin
- stdout
- tail
- union