|
Determinism, in that given some set of inputs you only ever receive one output. Non-determinism, in that given some set of inputs it's possible to receive a collection (a list) of possible outputs. With lists you can express things like all possible pairings of all possible outcomes, or the Cartesian product: ghci> liftM2 (,) ['a', 'b', 'c'] [1,2,3]
[('a',1),('a',2),('a',3),('b',1),('b',2),('b',3),('c',1),('c',2),('c',3)]
... or in more explicit monadic do-notation: ghci> :{
ghci| do
ghci| x <- ['a', 'b', 'c']
ghci| y <- [1,2,3]
ghci| return (x, y)
ghci| :}
[('a',1),('a',2),('a',3),('b',1),('b',2),('b',3),('c',1),('c',2),('c',3)]
and so on. |