
17 Jul
2009
17 Jul
'09
6:36 a.m.
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.