Given a set [1,2,3] the power set is unique. Why do we say it's non deterministic? Consider another example
[1,2] >>= \n -> ['a','b'] >>= \ch -> return (n,ch)
Why is this function non-deterministic?
If I consider \ch -> return (n,ch) as the second function where is the first?
And if the first function is
\n -> ['a','b'] >>= \ch -> return (n,ch)
Why is it evaluation from right to left.
Shouldn't it be \n -> (function)?
And what function is this (['a','b'] >>= \ch -> return (n,ch))?
If it's left to right It can't evaluate the second \ch function without using the first part ['a','b'] which doesn't have to do anything with 'n' parameter.
The reason why the term non-determinism is sometimes used when talking about the list monad is because of denotational semantics. When giving semantics to non-deterministic languages it is common to use the power domain. This domain can be approximated in Haskell using lists. Since the use of monads in Haskell comes from their use in denotational semantics, some of the terms used in that field have been carried over even though they may or may not make sense in their new context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With