-- 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. @package NanoProlog @version 0.2.1 module Language.Prolog.NanoProlog.NanoProlog type Env = Map UpperCase Term type LowerCase = 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 emptyEnv :: Maybe (Map UpperCase t) enumerateDepthFirst :: Proofs -> Result -> [(Proofs, Env)] matches :: (Term, Term) -> Maybe Env -> Maybe Env pFun :: Parser Term pRule :: Parser Rule pTerm :: Parser Term pTerms :: Parser [Term] -- | printEnv prints a single solution, showing only the variables -- that were introduced in the original goal show' :: Env -> String solve :: [Rule] -> Maybe Env -> [TaggedTerm] -> Result startParse :: (ListLike s b, Show b) => P (Str b s LineColPos) a -> s -> (a, [Error LineColPos]) unify :: (Term, Term) -> Maybe Env -> Maybe Env instance Eq Term instance Ord Term instance Eq Rule instance Show Rule instance Show Term 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.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 ()