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

Gleb Alexeyev gleb.alexeev at gmail.com
Fri Jul 17 06:36:07 EDT 2009

Thomas Hartman wrote:
> on haskell reddit today
> powerSet = filterM (const [True, False])

Does it help if we inline the 'const' function and rewrite [True, False] 
in monadic notation as (return True `mplus` return False)?

powerSet = filterM (\x -> return True `mplus` return False).

You can see that 'x' is ignored, both True and False are returned, hence 
  x is preserved in one answer and not preserved in another.

More information about the Haskell-Cafe mailing list