@hackage g2q0.1.0.0

G2Q allows constraint programming, via writing Haskell predicates.

  • Installation

  • Dependencies (2)

  • Dependents (0)

G2Q


About

G2Q allows constraint programming, via writing Haskell predicates. A quasiquoter, g2, is provided which can take concrete arguments at runtime, and solve for unknown symbolic arguments.

For example, to find inputs from a list xs which sum to a given number n, you can write:

sumToN :: Int -> [Int] -> IO (Maybe [Int])
sumToN = [g2| \(n :: Int) (xs :: [Int]) ->
              ?(ys :: [Int])
            |  sum ys == n
            && all (\e -> e `elem` xs) ys
            && length ys >= 1 |]