packages feed

NanoProlog 0.2.1 → 0.2.2

raw patch · 4 files changed

+19/−8 lines, 4 filesdep +haskell98PVP ok

version bump matches the API change (PVP)

Dependencies added: haskell98

API changes (from Hackage documentation)

Files

NanoProlog.cabal view
@@ -1,5 +1,5 @@ Name:                NanoProlog-Version:             0.2.1+Version:             0.2.2 Synopsis:            Very small  interpreter for a Prolog-like language Description:         This package was developed to demonstrate the ideas behind                      the Prolog language. It contains a very small interpreter@@ -31,6 +31,7 @@  Library   Build-Depends:	  base >= 4.0 && < 5.0,+                    haskell98 >= 1.1.0.1,                     uu-parsinglib >= 2.7.1,                     ListLike == 3.1.*,                     containers == 0.4.*
royals.pro view
@@ -13,6 +13,12 @@ ma(max,ale). ma(max,ama). ma(max,ari).+ma(bea,con).+ma(bea,fri).++elem(X, cons(X,Y)).+elem(X, cons(Z,Y)) :- elem (X, Y).+man(X) :- elem(X, cons(claus, cons(alex, cons(con, cons(fri, empty))))).  ouder(X,Y) :- pa(X,Y). ouder(X,Y) :- ma(X,Y).
src/Language/Prolog/NanoProlog/Interpreter.hs view
@@ -2,6 +2,7 @@  import            Language.Prolog.NanoProlog.NanoProlog import            Text.ParserCombinators.UU+import            System (getArgs) import            System.IO  -- * Running the Interpreter@@ -9,10 +10,13 @@ -- | The `main` program prompt for a file with Prolog rules and call the main -- interpreter loop run :: IO ()-run =  do  hSetBuffering stdin LineBuffering-           putStrLn "File with rules?"-           fn  <- getLine-           s   <- readFile fn+run =  do  args  <- getArgs+           fn    <- case args of+                      []     -> do  hSetBuffering stdin LineBuffering+                                    putStrLn "File with rules?"+                                    getLine+                      (x:_)  -> return x+           s     <- readFile fn            let (rules, errors) = startParse (pList pRule) s            if null errors  then  do  mapM_ print rules                                      loop rules
src/Language/Prolog/NanoProlog/NanoProlog.hs view
@@ -101,9 +101,9 @@            |  otherwise                         = Nothing  solve :: [Rule] -> Maybe Env  -> [TaggedTerm] -> Result-solve _      Nothing   _        = ApplyRules []-solve _      (Just e)    []     = Done e-solve rules  e  ((tg,t):ts)  = ApplyRules+solve _      Nothing   _            = ApplyRules []+solve _      (Just e)  []           = Done e+solve rules  e         ((tg,t):ts)  = ApplyRules   [  let  cts = map ((tg ++) . ('.' :) . show) ([1..] :: [Int]) `zip` cs ++ ts      in   (tg, rule, solve rules (unify (t, c) e) cts)   |  rule@(c :<-: cs)  <- tag tg rules