Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use transformers instead of mtl

  • Loading branch information...
commit c3ece42b48231615e1d9e0377485df980798b1c4 1 parent 7049f25
@travitch authored
View
6 datalog.cabal
@@ -42,17 +42,17 @@ library
ghc-options: -Wall -auto-all
ghc-prof-options: -auto-all
-executable repl
+executable datalog-repl
+ default-language: Haskell2010
main-is: repl.hs
hs-source-dirs: src
ghc-options: -Wall -auto-all
build-depends: base == 4.*,
containers,
- datalog,
+ datalog == 0.1.0.0,
failure,
hashable,
haskeline,
- mtl,
parsec,
pretty,
text,
View
5 src/Database/Datalog/REPL/Datalog.hs
@@ -12,8 +12,9 @@ module Database.Datalog.REPL.Datalog
) where
-import Data.Hashable
-import Control.Monad.State
+import Data.Hashable hiding ( combine )
+import Control.Monad ( liftM )
+import Control.Monad.Trans.State
import Data.Map (Map)
import Data.Maybe
import Data.Text hiding (map,concatMap)
View
22 src/Database/Datalog/REPL/Parser.hs
@@ -22,7 +22,7 @@ import qualified Data.Map as M
import Data.Map (Map)
import Control.Applicative ((<$>))
-import Control.Monad.State
+import Control.Monad ( forM_, when )
import Data.Either (partitionEithers)
@@ -38,13 +38,13 @@ type P = Parsec Text Env
instance (Monad m) => Stream Text m Char where
uncons = return . T.uncons
-data Env = Env
+data Env = Env
{ envConMap :: Map String Con
, envNextFree :: !Id
} deriving (Show)
initialEnv :: Env
-initialEnv = Env { envNextFree = 0, envConMap = M.empty }
+initialEnv = Env { envNextFree = 0, envConMap = M.empty }
fresh :: P Int
fresh = do
@@ -61,7 +61,7 @@ mkCon k = do
Nothing -> do
i <- fresh
let result = C i k
- modifyState $ \env -> env { envConMap = M.insert k result m }
+ modifyState $ \env -> env { envConMap = M.insert k result m }
return result
-- parser
@@ -85,7 +85,7 @@ neg :: P ()
neg = (string "\\+" <|> string "~") >> return ()
term :: P Term
-term = Var <$> var
+term = Var <$> var
<|> Con <$> con
@@ -105,7 +105,7 @@ close :: P ()
close = (spaces >> char ')' >> return ()) <?> ")"
betweenParens :: P a -> P a
-betweenParens = between open close
+betweenParens = between open close
spaced :: P a -> P a
spaced = between spaces spaces
@@ -118,7 +118,7 @@ atom t = do
pat :: P Pat
pat = do { neg; spaces; Not <$> atom term } <|> Pat <$> atom term
-
+
fact :: P (Atom Con)
fact = atom con
<?> "fact"
@@ -138,10 +138,10 @@ rule = do
safe :: Rule -> P Rule
safe rule@(Rule head body) = do
- forM_ headVars $ \v ->
+ forM_ headVars $ \v ->
when (v `notElem` bodyVars) $ do
unexpected $ "variable " ++ show (varName v) ++ " appears in head, but not occur positively in body"
- forM_ subVars $ \v ->
+ forM_ subVars $ \v ->
when (v `notElem` bodyVars) $ do
unexpected $ "variable " ++ show (varName v) ++ " appears in a negated subgoal, but not occur positively in body"
return rule
@@ -159,12 +159,12 @@ safe rule@(Rule head body) = do
statement :: P (Either Fact Rule)
statement = try (Left <$> fact)
- <|> (Right <$> rule)
+ <|> (Right <$> rule)
lineSep :: P ()
lineSep = spaced period <?> "."
statements :: P ([Fact],[Rule])
-statements = do
+statements = do
spaces
result <- partitionEithers <$> statement `sepEndBy` lineSep
eof
View
4 src/Database/Datalog/REPL/REPL.hs
@@ -8,7 +8,9 @@ module Database.Datalog.REPL.REPL
, repl
) where
-import Control.Monad.State
+import Control.Monad ( liftM )
+import Control.Monad.Trans.Class
+import Control.Monad.Trans.State
import Data.IORef
import Data.Monoid
import Database.Datalog.REPL.Backend
Please sign in to comment.
Something went wrong with that request. Please try again.