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.

Cheers,
Sebastian

[1]: http://www.curry-language.org/
[2]: unfortunately not yet in the mailing list archive (<http://www.informatik.uni-kiel.de/~mh/curry/listarchive/ > Thread title: "beautiful non-determinism")


--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to