Fix warnings in 16 modules, mostly forward compatibility warnings from GHC 7.8

This commit is contained in:
hallgren
2014-08-13 22:16:18 +00:00
parent a06351b625
commit cd5193b7e1
16 changed files with 91 additions and 34 deletions

View File

@@ -5,10 +5,10 @@ import GF.Compile.ReadFiles(ModEnv,getOptionsFromFile,getAllFiles,
importsOfModule)
import GF.CompileOne(compileOne)
import GF.Grammar.Grammar(SourceGrammar,msrc,modules,emptySourceGrammar,
abstractOfConcrete,prependModule)
import GF.Grammar.Grammar(SourceGrammar,emptySourceGrammar,
abstractOfConcrete,prependModule)--,msrc,modules
import GF.Infra.Ident(Ident,identS,showIdent)
import GF.Infra.Ident(Ident,identS)--,showIdent
import GF.Infra.Option
import GF.Infra.UseIO(IOE,FullPath,liftIO,getLibraryDirectory,putIfVerb,
justModuleName,extendPathEnv,putStrE,putPointE)
@@ -17,7 +17,7 @@ import GF.Data.Operations(raise,(+++),err)
import Control.Monad(foldM,when)
import GF.System.Directory(doesFileExist,getModificationTime)
import System.FilePath((</>),isRelative,dropFileName)
import qualified Data.Map as Map(empty,insert,lookup,elems)
import qualified Data.Map as Map(empty,insert,elems) --lookup
import Data.List(nub)
import Data.Time(UTCTime)
import GF.Text.Pretty(render,($$),(<+>),nest)

View File

@@ -36,6 +36,7 @@ import Data.Array.IArray
import Data.Array.Unboxed
--import Data.Maybe
--import Data.Char (isDigit)
import Control.Applicative(Applicative(..))
import Control.Monad
import Control.Monad.Identity
--import Control.Exception
@@ -247,6 +248,10 @@ newtype CnvMonad a = CM {unCM :: SourceGrammar
-> ([ProtoFCat],[Symbol])
-> Branch b}
instance Applicative CnvMonad where
pure = return
(<*>) = ap
instance Monad CnvMonad where
return a = CM (\gr c s -> c a s)
CM m >>= k = CM (\gr c s -> m gr (\a s -> unCM (k a) gr c s) s)

View File

@@ -30,7 +30,7 @@ import GF.Compile.ReadFiles(parseSource,lift)
import qualified Data.ByteString.Char8 as BS
import Data.Char(isAscii)
import Control.Monad (foldM,when,unless)
import System.Cmd (system)
import System.Process (system)
import System.Directory(removeFile,getCurrentDirectory)
import System.FilePath(makeRelative)

View File

@@ -9,6 +9,8 @@ import GF.Compile.TypeCheck.Primitives
import GF.Infra.CheckM
--import GF.Infra.UseIO
import GF.Data.Operations
import Control.Applicative(Applicative(..))
import Control.Monad(ap)
import GF.Text.Pretty
import Data.List (nub, (\\), tails)
@@ -467,6 +469,10 @@ instance Monad TcM where
TcFail msgs -> TcFail msgs)
fail = tcError . pp
instance Applicative TcM where
pure = return
(<*>) = ap
instance Functor TcM where
fmap f g = TcM (\ms msgs -> case unTcM g ms msgs of
TcOk x ms msgs -> TcOk (f x) ms msgs

View File

@@ -29,6 +29,7 @@ module GF.Data.BacktrackM (
) where
import Data.List
import Control.Applicative
import Control.Monad
import Control.Monad.State.Class
@@ -60,6 +61,10 @@ foldFinalStates f b (BM m) s = m (\x s b -> f s b) s b
finalStates :: BacktrackM s () -> s -> [s]
finalStates bm = map fst . runBM bm
instance Applicative (BacktrackM s) where
pure = return
(<*>) = ap
instance Monad (BacktrackM s) where
return a = BM (\c s b -> c a s b)
BM m >>= k = BM (\c s b -> m (\a s b -> unBM (k a) c s b) s b)
@@ -69,6 +74,10 @@ instance Monad (BacktrackM s) where
instance Functor (BacktrackM s) where
fmap f (BM m) = BM (\c s b -> m (\a s b -> c (f a) s b) s b)
instance Alternative (BacktrackM s) where
empty = mzero
(<|>) = mplus
instance MonadPlus (BacktrackM s) where
mzero = BM (\c s b -> b)
(BM f) `mplus` (BM g) = BM (\c s b -> g c s $! f c s b)

View File

@@ -14,7 +14,8 @@
module GF.Data.ErrM (Err(..)) where
import Control.Monad (MonadPlus(..))
import Control.Monad (MonadPlus(..),ap)
import Control.Applicative
-- | like @Maybe@ type with error msgs
data Err a = Ok a | Bad String
@@ -31,8 +32,16 @@ instance Functor Err where
fmap f (Ok a) = Ok (f a)
fmap f (Bad s) = Bad s
instance Applicative Err where
pure = return
(<*>) = ap
-- | added by KJ
instance MonadPlus Err where
mzero = Bad "error (no reason given)"
mplus (Ok a) _ = Ok a
mplus (Bad s) b = b
instance Alternative Err where
empty = mzero
(<|>) = mplus

View File

@@ -67,7 +67,8 @@ import Data.Char (isSpace, toUpper, isSpace, isDigit)
import Data.List (nub, partition, (\\))
import qualified Data.Map as Map
import Data.Map (Map)
import Control.Monad (liftM,liftM2)
import Control.Applicative(Applicative(..))
import Control.Monad (liftM,liftM2,ap)
import GF.Data.ErrM
import GF.Data.Relation
@@ -330,6 +331,10 @@ stmr f = stm (\s -> return (f s))
instance Functor (STM s) where fmap = liftM
instance Applicative (STM s) where
pure = return
(<*>) = ap
instance Monad (STM s) where
return a = STM (\s -> return (a,s))
STM c >>= f = STM (\s -> do

View File

@@ -6,6 +6,8 @@ module GF.Grammar.Lexer
, isReservedWord
) where
import Control.Applicative
import Control.Monad(ap)
import GF.Infra.Ident
--import GF.Data.Operations
import qualified Data.ByteString.Char8 as BS
@@ -258,6 +260,13 @@ data ParseResult a
newtype P a = P { unP :: AlexInput -> ParseResult a }
instance Functor P where
fmap = (<$>)
instance Applicative P where
pure = return
(<*>) = ap
instance Monad P where
return a = a `seq` (P $ \s -> POk a)
(P m) >>= k = P $ \ s -> case m s of

View File

@@ -28,7 +28,8 @@ import qualified Data.Map as Map
import GF.Text.Pretty
import System.FilePath(makeRelative)
import Control.Parallel.Strategies(parList,rseq,using)
import Control.Monad(liftM)
import Control.Monad(liftM,ap)
import Control.Applicative(Applicative(..))
type Message = Doc
type Error = Message
@@ -50,6 +51,10 @@ instance Monad Check where
(ws,Success x) -> unCheck (g x) {-ctxt-} ws
(ws,Fail msg) -> (ws,Fail msg)
instance Applicative Check where
pure = return
(<*>) = ap
instance ErrorMonad Check where
raise s = checkError (pp s)
handle f h = handle' f (h . render)

View File

@@ -19,10 +19,11 @@ module GF.Infra.SIO(
restricted,restrictedSystem
) where
import Prelude hiding (putStrLn,print)
import Control.Monad(liftM)
import Control.Applicative(Applicative(..))
import Control.Monad(liftM,ap)
import System.IO(hPutStrLn,hFlush,stdout)
import GF.System.Catch(try)
import System.Cmd(system)
import System.Process(system)
import System.Environment(getEnv)
import Control.Concurrent.Chan(newChan,writeChan,getChanContents)
import qualified System.CPUTime as IO(getCPUTime)
@@ -39,6 +40,10 @@ newtype SIO a = SIO {unS::PutStrLn->IO a}
instance Functor SIO where fmap = liftM
instance Applicative SIO where
pure = return
(<*>) = ap
instance Monad SIO where
return x = SIO (const (return x))
SIO m1 >>= xm2 = SIO $ \ h -> m1 h >>= \ x -> unS (xm2 x) h

View File

@@ -31,6 +31,7 @@ import System.Exit
import System.CPUTime
--import System.Cmd
import Text.Printf
import Control.Applicative(Applicative(..))
import Control.Monad
import Control.Monad.Trans(MonadIO(..))
import Control.Exception(evaluate)
@@ -150,6 +151,10 @@ instance ErrorMonad IOE where
instance Functor IOE where fmap = liftM
instance Applicative IOE where
pure = return
(<*>) = ap
instance Monad IOE where
return a = ioe (return (return a))
IOE c >>= f = IOE $ do

View File

@@ -2,7 +2,7 @@ module GFC (mainGFC, writePGF) where
-- module Main where
import PGF
import PGF.Internal(PGF,concretes,optimizePGF,unionPGF)
import PGF.Internal(concretes,optimizePGF,unionPGF)
import PGF.Internal(putSplitAbs,encodeFile,runPut)
import GF.Compile
import GF.Compile.Export