-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Very small interpreter for a Prolog-like language
--
-- This package was developed to demonstrate the ideas behind the Prolog
-- language. It contains a very small interpreter
-- (Language.Prolog.Nanoprolog) which can be run on its own. It
-- reads a file with definitions, and then prompts for a goal. All
-- possibe solutions are printed, preceded by a tree showing which rules
-- were applied in which order.
--
-- The file royals.pro contains a description of part of the
-- Dutch royal family, whereas the file tc.pro shows unification
-- at work in a very small type inferencer.
@package NanoProlog
@version 0.3
module Language.Prolog.NanoProlog.NanoProlog
newtype Env
Env :: Map UpperCase Term -> Env
fromEnv :: Env -> Map UpperCase Term
type UpperCase = String
type LowerCase = String
type Tag = String
data Result
Done :: Env -> Result
ApplyRules :: [(Tag, Rule, Result)] -> Result
data Rule
(:<-:) :: Term -> [Term] -> Rule
class Subst t
subst :: Subst t => Env -> t -> t
class Taggable a
tag :: Taggable a => Tag -> a -> a
data Term
Var :: UpperCase -> Term
Fun :: LowerCase -> [Term] -> Term
type Proofs = [(Tag, Rule)]
type TaggedTerm = (Tag, Term)
emptyEnv :: Maybe Env
enumerateDepthFirst :: Proofs -> Result -> [(Proofs, Env)]
matches :: (Term, Term) -> Maybe Env -> Maybe Env
solve :: [Rule] -> Maybe Env -> [TaggedTerm] -> Result
unify :: (Term, Term) -> Maybe Env -> Maybe Env
instance Eq Term
instance Ord Term
instance Eq Rule
instance Show Rule
instance Show Term
instance Show Env
instance Subst Rule
instance Subst Term
instance Subst a => Subst [a]
instance Taggable a => Taggable [a]
instance Taggable Rule
instance Taggable Term
module Language.Prolog.NanoProlog.Parser
pTerm, pFun, pCons :: Parser Term
pRule :: Parser Rule
pTerms :: Parser [Term]
startParse :: (ListLike s b, Show b) => P (Str b s LineColPos) a -> s -> (a, [Error LineColPos])
module Language.Prolog.NanoProlog.Interpreter
-- | The main program prompt for a file with Prolog rules and call
-- the main interpreter loop
run :: IO ()
-- | loop ask for a goal, and enuartes all solutions found, each
-- preceded by a trace conatining the rules applied in a tree-like
-- fashion
loop :: [Rule] -> IO ()
-- | printSolutions takes the result of a treewalk, which constructs
-- all the proofs, and pairs them with their final substitutions.
-- Alternative approaches in printing are to print the raw proofs, i.e.
-- without applying the final substitution (remove the subst env
-- ). This nicely shows how the intermediate variables come into life. By
-- including the test on the length the facts directly stemming from the
-- data base are not printed. This makes the proofs much shorter, but a
-- bit less complete.
printSolutions :: Result -> IO ()