[Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell?

Sebastian Fischer sebf at informatik.uni-kiel.de
Tue Jul 28 04:58:53 EDT 2009


> 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.)



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090728/1718bff2/attachment.html


More information about the Haskell-Cafe mailing list