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

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

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

perms = sortByM (const [True,False]) This doesn't seem right, since the comparison function is inconsistent and moreover the results will depend on the sorting algorithm chosen. Ganesh === Please access the attached

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

On Tue, Jul 28, 2009 at 10:58:53AM +0200, Sebastian Fischer wrote: tails = dropWhileM (const [True,False]) Actually this should be tails = dropWhileM (const [False, True]) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

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

On Jul 28, 2009, at 11:06 AM, Sittampalam, Ganesh wrote: perms = sortByM (const [True,False]) This doesn't seem right, since the comparison function is inconsistent I was also wary about this point, e.g. QuickSort depends on transitivity. and moreover the results will depend on the

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

Sebastian Fischer wrote: On Jul 28, 2009, at 11:06 AM, Sittampalam, Ganesh wrote: perms = sortByM (const [True,False]) and moreover the results will depend on the sorting algorithm chosen. Is it only that different sorting algorithms enumerate all permutations in different orders or is

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

On Tue, Jul 28, 2009 at 6:47 AM, Sebastian Fischers...@informatik.uni-kiel.de wrote: perms = sortByM (const [True,False]) Hence, perm as defined above can yield a list that contains all permutations of the input (at least once) regardless of the sorting algorithm. Where is the hitch? The

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

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,

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

On Fri, Jul 17, 2009 at 1:35 AM, Thomas Hartman tphya...@gmail.com wrote: on haskell reddit today powerSet = filterM (const [True, False]) 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

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

For each item, we ignore what the item actually is (hence `const`), and say that we both want it (True) and don't want it (False) in the output. Since we are using the list monad we are allowed to say this, and the filter function gives us a list of lists. I think there's probably a more intuitive

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

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