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

Yitzchak Gale gale at sefer.org
Fri Jul 17 08:29:22 EDT 2009


Thomas Hartman wrote:
> on haskell reddit today
> powerSet = filterM (const [True, False])
>
> is said to be beautiful / mind blowing.
> Is this a uniquely haskell obfu, or is there a way of reading this
> definition that makes sense?

To me, these are more obvious:

powerSet = map catMaybes . mapM ((mzero:).return.return)
powerSet = map concat . mapM ((mzero:).return.return)

They work by pretty much the same principle.
Perhaps they seem simpler to me only because
I use mapM a lot more than I use filterM.

Regards,
Yitz


More information about the Haskell-Cafe mailing list