Fri Aug 26 23:31:32 CEST 2011

The List Monad - Generate and Test

When people talk about logic programming with the list Monad, what is
meant are things like this:

  import Control.Monad

  f n = do
    x <- [1..n]
    y <- [1..n]
    z <- [1..n]
    guard $ (x^2 + y^2 == z^2)
    return (x,y,z)

This is one of those super elegant Haskell tricks ;)