module Control.CP.Solver where
import Control.Monad.Writer
import Data.Monoid
class Monad solver => Solver solver where
type Constraint solver :: *
type Label solver :: *
add :: Constraint solver -> solver Bool
run :: solver a -> a
mark :: solver (Label solver)
goto :: Label solver -> solver ()
class Solver solver => Term solver term where
newvar :: solver term
instance (Monoid w, Solver s) => Solver (WriterT w s) where
type Constraint (WriterT w s) = Constraint s
type Label (WriterT w s) = Label s
add = lift . add
run = fst . run . runWriterT
mark = lift mark
goto = lift . goto
instance (Monoid w, Term s t) => Term (WriterT w s) t where
newvar = lift newvar