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

Thomas Hartman tphyahoo at gmail.com
Fri Jul 17 05:35:21 EDT 2009

on haskell reddit today

powerSet = filterM (const [True, False])

is said to be beautiful / mind blowing. I just don't get it. I can
play with  transformations until I get

powerSet []       = [[]]
powerSet (x:xs) =
  let pxs = powerSet xs
  in map (x:) pxs ++ pxs

which is understandable to me, but no matter how long I look at the
original filterM definition it just doesn't click.

Is this a uniquely haskell obfu, or is there a way of reading this
definition that makes sense?

If anybody agrees with me, care to throw out other examples of
"obfuscated haskell considered harmful"?

More information about the Haskell-Cafe mailing list