mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-29 04:38:55 -06:00
Merge pull request #84 from ffrixslee/issue-46
Issue 46 (various deprecations during compilation of GF)
This commit is contained in:
@@ -528,7 +528,7 @@ value2term' stop loc xs v0 =
|
|||||||
-- VGlue v1 v2 -> Glue (v2t v1) (v2t v2)
|
-- VGlue v1 v2 -> Glue (v2t v1) (v2t v2)
|
||||||
-- VExtR v1 v2 -> ExtR (v2t v1) (v2t v2)
|
-- VExtR v1 v2 -> ExtR (v2t v1) (v2t v2)
|
||||||
VError err -> return (Error err)
|
VError err -> return (Error err)
|
||||||
_ -> bug ("value2term "++show loc++" : "++show v0)
|
|
||||||
where
|
where
|
||||||
v2t = v2txs xs
|
v2t = v2txs xs
|
||||||
v2txs = value2term' stop loc
|
v2txs = value2term' stop loc
|
||||||
|
|||||||
@@ -265,7 +265,6 @@ instance PPA LinPattern where
|
|||||||
RecordPattern r -> block r
|
RecordPattern r -> block r
|
||||||
TuplePattern ps -> "<"<>punctuate "," ps<>">"
|
TuplePattern ps -> "<"<>punctuate "," ps<>">"
|
||||||
WildPattern -> pp "_"
|
WildPattern -> pp "_"
|
||||||
_ -> parens p
|
|
||||||
|
|
||||||
instance RhsSeparator LinPattern where rhsSep _ = pp "="
|
instance RhsSeparator LinPattern where rhsSep _ = pp "="
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import qualified Data.Map as M
|
|||||||
import Control.Applicative -- for GHC<7.10
|
import Control.Applicative -- for GHC<7.10
|
||||||
import Control.Monad(when)
|
import Control.Monad(when)
|
||||||
import Control.Monad.State(StateT(..),get,gets,put)
|
import Control.Monad.State(StateT(..),get,gets,put)
|
||||||
import Control.Monad.Error(ErrorT(..),Error(..))
|
import Control.Monad.Except(ExceptT(..),runExceptT)
|
||||||
import System.Random(randomRIO)
|
import System.Random(randomRIO)
|
||||||
--import System.IO(stderr,hPutStrLn)
|
--import System.IO(stderr,hPutStrLn)
|
||||||
import GF.System.Catch(try)
|
import GF.System.Catch(try)
|
||||||
@@ -108,9 +108,9 @@ handle_fcgi execute1 state0 stateM cache =
|
|||||||
|
|
||||||
-- * Request handler
|
-- * Request handler
|
||||||
-- | Handler monad
|
-- | Handler monad
|
||||||
type HM s a = StateT (Q,s) (ErrorT Response IO) a
|
type HM s a = StateT (Q,s) (ExceptT Response IO) a
|
||||||
run :: HM s Response -> (Q,s) -> IO (s,Response)
|
run :: HM s Response -> (Q,s) -> IO (s,Response)
|
||||||
run m s = either bad ok =<< runErrorT (runStateT m s)
|
run m s = either bad ok =<< runExceptT (runStateT m s)
|
||||||
where
|
where
|
||||||
bad resp = return (snd s,resp)
|
bad resp = return (snd s,resp)
|
||||||
ok (resp,(qs,state)) = return (state,resp)
|
ok (resp,(qs,state)) = return (state,resp)
|
||||||
@@ -123,12 +123,12 @@ put_qs qs = do state <- get_state; put (qs,state)
|
|||||||
put_state state = do qs <- get_qs; put (qs,state)
|
put_state state = do qs <- get_qs; put (qs,state)
|
||||||
|
|
||||||
err :: Response -> HM s a
|
err :: Response -> HM s a
|
||||||
err e = StateT $ \ s -> ErrorT $ return $ Left e
|
err e = StateT $ \ s -> ExceptT $ return $ Left e
|
||||||
|
|
||||||
hmbracket_ :: IO () -> IO () -> HM s a -> HM s a
|
hmbracket_ :: IO () -> IO () -> HM s a -> HM s a
|
||||||
hmbracket_ pre post m =
|
hmbracket_ pre post m =
|
||||||
do s <- get
|
do s <- get
|
||||||
e <- liftIO $ bracket_ pre post $ runErrorT $ runStateT m s
|
e <- liftIO $ bracket_ pre post $ runExceptT $ runStateT m s
|
||||||
case e of
|
case e of
|
||||||
Left resp -> err resp
|
Left resp -> err resp
|
||||||
Right (a,s) -> do put s;return a
|
Right (a,s) -> do put s;return a
|
||||||
@@ -407,9 +407,6 @@ resp404 path = Response 404 [plain,xo] $ "Not found: "++path++"\n"
|
|||||||
resp500 msg = Response 500 [plain,xo] $ "Internal error: "++msg++"\n"
|
resp500 msg = Response 500 [plain,xo] $ "Internal error: "++msg++"\n"
|
||||||
resp501 msg = Response 501 [plain,xo] $ "Not implemented: "++msg++"\n"
|
resp501 msg = Response 501 [plain,xo] $ "Not implemented: "++msg++"\n"
|
||||||
|
|
||||||
instance Error Response where
|
|
||||||
noMsg = resp500 "no message"
|
|
||||||
strMsg = resp500
|
|
||||||
|
|
||||||
-- * Content types
|
-- * Content types
|
||||||
plain = ct "text/plain" ""
|
plain = ct "text/plain" ""
|
||||||
|
|||||||
@@ -9,14 +9,24 @@ instance JSON Grammar where
|
|||||||
showJSON (Grammar name extends abstract concretes) =
|
showJSON (Grammar name extends abstract concretes) =
|
||||||
makeObj ["basename".=name, "extends".=extends,
|
makeObj ["basename".=name, "extends".=extends,
|
||||||
"abstract".=abstract, "concretes".=concretes]
|
"abstract".=abstract, "concretes".=concretes]
|
||||||
|
readJSON = error "Grammar.readJSON intentionally not defined"
|
||||||
|
|
||||||
instance JSON Abstract where
|
instance JSON Abstract where
|
||||||
showJSON (Abstract startcat cats funs) =
|
showJSON (Abstract startcat cats funs) =
|
||||||
makeObj ["startcat".=startcat, "cats".=cats, "funs".=funs]
|
makeObj ["startcat".=startcat, "cats".=cats, "funs".=funs]
|
||||||
|
readJSON = error "Abstract.readJSON intentionally not defined"
|
||||||
|
|
||||||
instance JSON Fun where showJSON (Fun name typ) = signature name typ
|
instance JSON Fun where
|
||||||
instance JSON Param where showJSON (Param name rhs) = definition name rhs
|
showJSON (Fun name typ) = signature name typ
|
||||||
instance JSON Oper where showJSON (Oper name rhs) = definition name rhs
|
readJSON = error "Fun.readJSON intentionally not defined"
|
||||||
|
|
||||||
|
instance JSON Param where
|
||||||
|
showJSON (Param name rhs) = definition name rhs
|
||||||
|
readJSON = error "Param.readJSON intentionally not defined"
|
||||||
|
|
||||||
|
instance JSON Oper where
|
||||||
|
showJSON (Oper name rhs) = definition name rhs
|
||||||
|
readJSON = error "Oper.readJSON intentionally not defined"
|
||||||
|
|
||||||
signature name typ = makeObj ["name".=name,"type".=typ]
|
signature name typ = makeObj ["name".=name,"type".=typ]
|
||||||
definition name rhs = makeObj ["name".=name,"rhs".=rhs]
|
definition name rhs = makeObj ["name".=name,"rhs".=rhs]
|
||||||
@@ -26,12 +36,15 @@ instance JSON Concrete where
|
|||||||
makeObj ["langcode".=langcode, "opens".=opens,
|
makeObj ["langcode".=langcode, "opens".=opens,
|
||||||
"params".=params, "opers".=opers,
|
"params".=params, "opers".=opers,
|
||||||
"lincats".=lincats, "lins".=lins]
|
"lincats".=lincats, "lins".=lins]
|
||||||
|
readJSON = error "Concrete.readJSON intentionally not defined"
|
||||||
|
|
||||||
instance JSON Lincat where
|
instance JSON Lincat where
|
||||||
showJSON (Lincat cat lintype) = makeObj ["cat".=cat, "type".=lintype]
|
showJSON (Lincat cat lintype) = makeObj ["cat".=cat, "type".=lintype]
|
||||||
|
readJSON = error "Lincat.readJSON intentionally not defined"
|
||||||
|
|
||||||
instance JSON Lin where
|
instance JSON Lin where
|
||||||
showJSON (Lin fun args lin) = makeObj ["fun".=fun, "args".=args, "lin".=lin]
|
showJSON (Lin fun args lin) = makeObj ["fun".=fun, "args".=args, "lin".=lin]
|
||||||
|
readJSON = error "Lin.readJSON intentionally not defined"
|
||||||
|
|
||||||
infix 1 .=
|
infix 1 .=
|
||||||
name .= v = (name,showJSON v)
|
name .= v = (name,showJSON v)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ import qualified Data.ByteString.Lazy as L
|
|||||||
import Data.ByteString.Base (inlinePerformIO)
|
import Data.ByteString.Base (inlinePerformIO)
|
||||||
import qualified Data.ByteString.Base as S
|
import qualified Data.ByteString.Base as S
|
||||||
#else
|
#else
|
||||||
import Data.ByteString.Internal (inlinePerformIO)
|
import Data.ByteString.Internal (accursedUnutterablePerformIO)
|
||||||
import qualified Data.ByteString.Internal as S
|
import qualified Data.ByteString.Internal as S
|
||||||
--import qualified Data.ByteString.Lazy.Internal as L
|
--import qualified Data.ByteString.Lazy.Internal as L
|
||||||
#endif
|
#endif
|
||||||
@@ -199,7 +199,7 @@ defaultSize = 32 * k - overhead
|
|||||||
|
|
||||||
-- | Sequence an IO operation on the buffer
|
-- | Sequence an IO operation on the buffer
|
||||||
unsafeLiftIO :: (Buffer -> IO Buffer) -> Builder
|
unsafeLiftIO :: (Buffer -> IO Buffer) -> Builder
|
||||||
unsafeLiftIO f = Builder $ \ k buf -> inlinePerformIO $ do
|
unsafeLiftIO f = Builder $ \ k buf -> accursedUnutterablePerformIO $ do
|
||||||
buf' <- f buf
|
buf' <- f buf
|
||||||
return (k buf')
|
return (k buf')
|
||||||
{-# INLINE unsafeLiftIO #-}
|
{-# INLINE unsafeLiftIO #-}
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ readN n f = fmap f $ getBytes n
|
|||||||
getPtr :: Storable a => Int -> Get a
|
getPtr :: Storable a => Int -> Get a
|
||||||
getPtr n = do
|
getPtr n = do
|
||||||
(fp,o,_) <- readN n B.toForeignPtr
|
(fp,o,_) <- readN n B.toForeignPtr
|
||||||
return . B.inlinePerformIO $ withForeignPtr fp $ \p -> peek (castPtr $ p `plusPtr` o)
|
return . B.accursedUnutterablePerformIO $ withForeignPtr fp $ \p -> peek (castPtr $ p `plusPtr` o)
|
||||||
{- INLINE getPtr -}
|
{- INLINE getPtr -}
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import Control.Applicative
|
|||||||
import Control.Monad
|
import Control.Monad
|
||||||
--import Control.Monad.Identity
|
--import Control.Monad.Identity
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
import Control.Monad.Error
|
import Control.Monad.Except
|
||||||
import Text.PrettyPrint
|
import Text.PrettyPrint
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|||||||
@@ -1032,6 +1032,7 @@ instance JSON PGF.Trie where
|
|||||||
showJSON (PGF.Ap f [[]]) = makeObj ["fun".=f] -- leaf
|
showJSON (PGF.Ap f [[]]) = makeObj ["fun".=f] -- leaf
|
||||||
-- showJSON (PGF.Ap f [es]) = makeObj ["fun".=f,"children".=es] -- one alternative
|
-- showJSON (PGF.Ap f [es]) = makeObj ["fun".=f,"children".=es] -- one alternative
|
||||||
showJSON (PGF.Ap f alts) = makeObj ["fun".=f,"alts".=alts]
|
showJSON (PGF.Ap f alts) = makeObj ["fun".=f,"alts".=alts]
|
||||||
|
readJSON = error "PGF.Trie.readJSON intentionally not defined"
|
||||||
|
|
||||||
instance JSON PGF.CId where
|
instance JSON PGF.CId where
|
||||||
readJSON x = readJSON x >>= maybe (fail "Bad language.") return . PGF.readLanguage
|
readJSON x = readJSON x >>= maybe (fail "Bad language.") return . PGF.readLanguage
|
||||||
|
|||||||
Reference in New Issue
Block a user