The M is the list, i.e. nondeterminism monad. For each element in the list, there is one return value where it appears (True), and one where it does not (False).

This discussion made Curry [1] programmers realise the beauty of non- determinism and lead to interesting reformulations of common list functions [2].

Here are some of them translated to Haskell:

inits = takeWhileM (const [True,False])
tails = dropWhileM (const [True,False])
perms = sortByM (const [True,False])

Only that Hoogle does not know any of these monadic helper functions.


[2]: unfortunately not yet in the mailing list archive (< > Thread title: "beautiful non-determinism")

Underestimating the novelty of the future is a time-honored tradition.

Haskell-Cafe mailing list

Reply via email to