forked from GitHub/gf-core
Replace all the different ErrM.hs modules with GF.Data.ErrM.
This commit is contained in:
@@ -18,7 +18,7 @@ import GF.GFCC.Macros
|
||||
import GF.Devel.PrintGFCC
|
||||
import GF.GFCC.DataGFCC ----
|
||||
|
||||
import GF.Command.ErrM ----
|
||||
import GF.Data.ErrM ----
|
||||
|
||||
import qualified Data.Map as Map
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
-- BNF Converter: Error Monad
|
||||
-- Copyright (C) 2004 Author: Aarne Ranta
|
||||
|
||||
-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
|
||||
module GF.Command.ErrM where
|
||||
|
||||
-- the Error monad: like Maybe type with error msgs
|
||||
|
||||
import Control.Monad (MonadPlus(..), liftM)
|
||||
|
||||
data Err a = Ok a | Bad String
|
||||
deriving (Read, Show, Eq, Ord)
|
||||
|
||||
instance Monad Err where
|
||||
return = Ok
|
||||
fail = Bad
|
||||
Ok a >>= f = f a
|
||||
Bad s >>= f = Bad s
|
||||
|
||||
instance Functor Err where
|
||||
fmap = liftM
|
||||
|
||||
instance MonadPlus Err where
|
||||
mzero = Bad "Err.mzero"
|
||||
mplus (Bad _) y = y
|
||||
mplus x _ = x
|
||||
@@ -11,7 +11,7 @@ import GF.GFCC.API
|
||||
import GF.GFCC.Macros
|
||||
import GF.GFCC.DataGFCC
|
||||
|
||||
import GF.Command.ErrM ----
|
||||
import GF.Data.ErrM ----
|
||||
|
||||
import qualified Data.Map as Map
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import GF.GFCC.Macros
|
||||
import qualified GF.Command.ParGFShell as P
|
||||
import GF.Command.PrintGFShell
|
||||
import GF.Command.AbsGFShell
|
||||
import GF.Command.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
pTree :: String -> Exp
|
||||
pTree s = case P.pTree (P.myLexer s) of
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module GF.Command.ParGFShell where
|
||||
import GF.Command.AbsGFShell
|
||||
import GF.Command.LexGFShell
|
||||
import GF.Command.ErrM
|
||||
import GF.Data.ErrM
|
||||
#if __GLASGOW_HASKELL__ >= 503
|
||||
import Data.Array
|
||||
#else
|
||||
|
||||
@@ -16,5 +16,5 @@ module GF.Data.ErrM (
|
||||
module GF.Data.Operations
|
||||
) where
|
||||
|
||||
import GF.Data.Operations
|
||||
import GF.Data.Operations (Err(..))
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import GF.GFCC.Raw.ConvertGFCC
|
||||
import GF.Devel.UseIO
|
||||
import GF.Infra.Option
|
||||
import GF.GFCC.API
|
||||
import GF.GFCC.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
mainGFC :: [String] -> IO ()
|
||||
mainGFC xx = do
|
||||
|
||||
@@ -12,7 +12,7 @@ import GF.GFCC.Raw.ConvertGFCC
|
||||
import GF.Devel.UseIO
|
||||
import GF.Infra.Option
|
||||
import GF.GFCC.API
|
||||
import GF.GFCC.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
mainGFC :: [String] -> IO ()
|
||||
mainGFC xx = do
|
||||
|
||||
@@ -24,7 +24,7 @@ import GF.GFCC.Raw.ConvertGFCC
|
||||
import GF.GFCC.Raw.ParGFCCRaw
|
||||
import GF.Command.PPrTree
|
||||
|
||||
import GF.GFCC.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
import GF.Parsing.FCFG
|
||||
import GF.Conversion.SimpleToFCFG (convertGrammar)
|
||||
|
||||
@@ -3,7 +3,7 @@ module GF.GFCC.CheckGFCC (checkGFCC, checkGFCCio, checkGFCCmaybe) where
|
||||
import GF.GFCC.CId
|
||||
import GF.GFCC.Macros
|
||||
import GF.GFCC.DataGFCC
|
||||
import GF.GFCC.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
import qualified Data.Map as Map
|
||||
import Control.Monad
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
-- BNF Converter: Error Monad
|
||||
-- Copyright (C) 2004 Author: Aarne Ranta
|
||||
|
||||
-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
|
||||
module GF.GFCC.ErrM where
|
||||
|
||||
-- the Error monad: like Maybe type with error msgs
|
||||
|
||||
import Control.Monad (MonadPlus(..), liftM)
|
||||
|
||||
data Err a = Ok a | Bad String
|
||||
deriving (Read, Show, Eq, Ord)
|
||||
|
||||
instance Monad Err where
|
||||
return = Ok
|
||||
fail = Bad
|
||||
Ok a >>= f = f a
|
||||
Bad s >>= f = Bad s
|
||||
|
||||
instance Functor Err where
|
||||
fmap = liftM
|
||||
|
||||
instance MonadPlus Err where
|
||||
mzero = Bad "Err.mzero"
|
||||
mplus (Bad _) y = y
|
||||
mplus x _ = x
|
||||
@@ -1,26 +0,0 @@
|
||||
-- BNF Converter: Error Monad
|
||||
-- Copyright (C) 2004 Author: Aarne Ranta
|
||||
|
||||
-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
|
||||
module GF.GFCC.Raw.ErrM where
|
||||
|
||||
-- the Error monad: like Maybe type with error msgs
|
||||
|
||||
import Control.Monad (MonadPlus(..), liftM)
|
||||
|
||||
data Err a = Ok a | Bad String
|
||||
deriving (Read, Show, Eq, Ord)
|
||||
|
||||
instance Monad Err where
|
||||
return = Ok
|
||||
fail = Bad
|
||||
Ok a >>= f = f a
|
||||
Bad s >>= f = Bad s
|
||||
|
||||
instance Functor Err where
|
||||
fmap = liftM
|
||||
|
||||
instance MonadPlus Err where
|
||||
mzero = Bad "Err.mzero"
|
||||
mplus (Bad _) y = y
|
||||
mplus x _ = x
|
||||
@@ -3,7 +3,7 @@
|
||||
module GF.GFCC.Raw.ParGFCCRaw (parseGrammar) where
|
||||
import GF.GFCC.Raw.AbsGFCCRaw
|
||||
import GF.GFCC.Raw.LexGFCCRaw
|
||||
import GF.GFCC.Raw.ErrM
|
||||
import GF.Data.ErrM
|
||||
#if __GLASGOW_HASKELL__ >= 503
|
||||
import Data.Array
|
||||
#else
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
module GF.GFCC.Raw.ParGFCCRaw (parseGrammar) where
|
||||
import GF.GFCC.Raw.AbsGFCCRaw
|
||||
import GF.GFCC.Raw.LexGFCCRaw
|
||||
import GF.GFCC.Raw.ErrM
|
||||
import GF.Data.ErrM
|
||||
}
|
||||
|
||||
%name pGrammar Grammar
|
||||
|
||||
@@ -3,7 +3,7 @@ module GF.GFCC.SkelGFCC where
|
||||
-- Haskell module generated by the BNF converter
|
||||
|
||||
import GF.GFCC.AbsGFCC
|
||||
import GF.GFCC.ErrM
|
||||
import GF.Data.ErrM
|
||||
type Result = Err String
|
||||
|
||||
failure :: Show a => a -> Result
|
||||
|
||||
@@ -14,7 +14,7 @@ import GF.GFCC.AbsGFCC
|
||||
|
||||
|
||||
|
||||
import GF.GFCC.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
type ParseFun a = [Token] -> Err a
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
-- BNF Converter: Error Monad
|
||||
-- Copyright (C) 2004 Author: Aarne Ranta
|
||||
|
||||
-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
|
||||
module GF.JavaScript.ErrM where
|
||||
|
||||
-- the Error monad: like Maybe type with error msgs
|
||||
|
||||
data Err a = Ok a | Bad String
|
||||
deriving (Read, Show, Eq)
|
||||
|
||||
instance Monad Err where
|
||||
return = Ok
|
||||
fail = Bad
|
||||
Ok a >>= f = f a
|
||||
Bad s >>= f = Bad s
|
||||
@@ -3,7 +3,7 @@
|
||||
module GF.JavaScript.ParJS where
|
||||
import GF.JavaScript.AbsJS
|
||||
import GF.JavaScript.LexJS
|
||||
import GF.JavaScript.ErrM
|
||||
import GF.Data.ErrM
|
||||
#if __GLASGOW_HASKELL__ >= 503
|
||||
import Data.Array
|
||||
#else
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
module GF.JavaScript.ParJS where
|
||||
import GF.JavaScript.AbsJS
|
||||
import GF.JavaScript.LexJS
|
||||
import GF.JavaScript.ErrM
|
||||
import GF.Data.ErrM
|
||||
}
|
||||
|
||||
%name pProgram Program
|
||||
|
||||
@@ -3,7 +3,7 @@ module GF.JavaScript.SkelJS where
|
||||
-- Haskell module generated by the BNF converter
|
||||
|
||||
import GF.JavaScript.AbsJS
|
||||
import GF.JavaScript.ErrM
|
||||
import GF.Data.ErrM
|
||||
type Result = Err String
|
||||
|
||||
failure :: Show a => a -> Result
|
||||
|
||||
@@ -14,7 +14,7 @@ import GF.JavaScript.AbsJS
|
||||
|
||||
|
||||
|
||||
import GF.JavaScript.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
type ParseFun a = [Token] -> Err a
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import GF.Parsing.FCFG.PInfo
|
||||
import GF.GFCC.DataGFCC
|
||||
import GF.GFCC.CId
|
||||
import GF.GFCC.Macros
|
||||
import GF.GFCC.ErrM
|
||||
import GF.Data.ErrM
|
||||
|
||||
import qualified Data.Map as Map
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@ import GF.System.Tracing
|
||||
import GF.Infra.Print
|
||||
import qualified GF.Grammar.PrGrammar as PrGrammar
|
||||
|
||||
import GF.Data.Operations (Err(..))
|
||||
import GF.Data.ErrM
|
||||
|
||||
import qualified GF.Grammar.Grammar as Grammar
|
||||
import qualified GF.Grammar.Macros as Macros
|
||||
import qualified GF.Canon.AbsGFC as AbsGFC
|
||||
import qualified GF.GFCC.DataGFCC as AbsGFCC
|
||||
import GF.GFCC.CId
|
||||
import qualified GF.GFCC.ErrM as ErrM
|
||||
import qualified GF.Infra.Ident as Ident
|
||||
import GF.CF.CFIdent (CFCat, cfCat2Ident, CFTok, wordsCFTok, prCFTok)
|
||||
|
||||
@@ -73,7 +72,7 @@ parse :: String -- ^ parsing algorithm (mcfg or cfg)
|
||||
-> Ident.Ident -- ^ abstract module name
|
||||
-> CFCat -- ^ starting category
|
||||
-> [CFTok] -- ^ input tokens
|
||||
-> GF.Data.Operations.Err [Grammar.Term] -- ^ resulting GF terms
|
||||
-> Err [Grammar.Term] -- ^ resulting GF terms
|
||||
|
||||
|
||||
-- parsing via CFG
|
||||
@@ -137,8 +136,8 @@ parse "f" strategy pinfo abs startCat inString =
|
||||
let Ident.IC x = cfCat2Ident startCat
|
||||
cat' = CId x
|
||||
in case PF.parseFCF strategy (fcfPInfo pinfo) cat' (map prCFTok inString) of
|
||||
ErrM.Ok es -> Ok (map (exp2term abs) es)
|
||||
ErrM.Bad msg -> Bad msg
|
||||
Ok es -> Ok (map (exp2term abs) es)
|
||||
Bad msg -> Bad msg
|
||||
|
||||
|
||||
-- error parser:
|
||||
|
||||
Reference in New Issue
Block a user