Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generic.Unification.Hinze
Description
Following the paper "Prolog control constructs in a functional setting" by Hinze, because I only want a clear denotational semantic for now. This is done as an experiment, and will not be part of the final package.
Synopsis
- class Monad m => Backtr m where
- class Backtr m => Cut m where
- naf :: Backtr m => m a -> m ()
- naf2 :: Cut m => m a -> m ()
- only :: Cut m => a -> m a
- newtype BacktrT m a = BacktrT {
- (>>-) :: forall ans. CPS a (m ans -> m ans)
- newtype CutT m a = CutT {
- (>>--) :: forall ans. CPS a (m (Answer m ans) -> m (Answer m ans))
- newtype Logic a = Logic {
- unLogic :: UnificationT (CutT Identity) a
- runLogic :: Logic a -> [Either UnificationError (a, Substitution)]
- evalLogic :: Logic a -> [a]
- (===) :: Unifiable a => Term a -> Term a -> Logic (Term a)
Documentation
class Monad m => Backtr m where #
Important classes
Methods
No solutions, corresponds to fail in prolog
Non-deterministing choice between two branches
Encapsulation, find one solution
Encapsulation, find all solutions
class Backtr m => Cut m where #
Methods
like in prolog, cut discards choicepoints
to delimit the effect of a cut in a region
Equivalent to once/1 in prolog. Note, the once function in the typeclass is the encapsulated version of this operation.
Constructors
Logic | |
Fields
|
Instances
Monad Logic # | |
Functor Logic # | |
Applicative Logic # | |
Cut Logic # | |
Backtr Logic # | |
MonadState Substitution Logic # | |
Defined in Generic.Unification.Hinze Methods get :: Logic Substitution # put :: Substitution -> Logic () # state :: (Substitution -> (a, Substitution)) -> Logic a # | |
MonadError UnificationError Logic # | |
Defined in Generic.Unification.Hinze Methods throwError :: UnificationError -> Logic a # catchError :: Logic a -> (UnificationError -> Logic a) -> Logic a # |
runLogic :: Logic a -> [Either UnificationError (a, Substitution)] #