module GF.Grammar.Binary(VersionTagged(..),decodeModuleHeader,decodeModule,encodeModule) where
import Prelude hiding (catch)
import Control.Exception(catch,ErrorCall(..),throwIO)
import PGF.Internal(Binary(..),Word8,putWord8,getWord8,encodeFile,decodeFile)
import qualified Data.Map as Map(empty)
import qualified Data.ByteString.Char8 as BS
import GF.Data.Operations
import GF.Infra.Ident
import GF.Infra.Option
import GF.Infra.UseIO(MonadIO(..))
import GF.Grammar.Grammar
import PGF()
import PGF.Internal(Literal(..))
gfoVersion :: [Char]
gfoVersion = [Char]
"GF04"
instance Binary Ident where
put :: Ident -> Put
put Ident
id = ByteString -> Put
forall t. Binary t => t -> Put
put (Ident -> ByteString
ident2utf8 Ident
id)
get :: Get Ident
get = do ByteString
bs <- Get ByteString
forall t. Binary t => Get t
get
if ByteString
bs ByteString -> ByteString -> Bool
forall a. Eq a => a -> a -> Bool
== [Char] -> ByteString
BS.pack [Char]
"_"
then Ident -> Get Ident
forall (m :: * -> *) a. Monad m => a -> m a
return Ident
identW
else Ident -> Get Ident
forall (m :: * -> *) a. Monad m => a -> m a
return (RawIdent -> Ident
identC (ByteString -> RawIdent
rawIdentC ByteString
bs))
instance Binary ModuleName where
put :: ModuleName -> Put
put (MN Ident
id) = Ident -> Put
forall t. Binary t => t -> Put
put Ident
id
get :: Get ModuleName
get = (Ident -> ModuleName) -> Get Ident -> Get ModuleName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ident -> ModuleName
MN Get Ident
forall t. Binary t => Get t
get
instance Binary Grammar where
put :: Grammar -> Put
put = [Module] -> Put
forall t. Binary t => t -> Put
put ([Module] -> Put) -> (Grammar -> [Module]) -> Grammar -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Grammar -> [Module]
modules
get :: Get Grammar
get = ([Module] -> Grammar) -> Get [Module] -> Get Grammar
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Module] -> Grammar
mGrammar Get [Module]
forall t. Binary t => Get t
get
instance Binary ModuleInfo where
put :: ModuleInfo -> Put
put ModuleInfo
mi = do (ModuleType, ModuleStatus, Options, [(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char], Maybe (Array SeqId Sequence),
Map Ident Info)
-> Put
forall t. Binary t => t -> Put
put (ModuleInfo -> ModuleType
mtype ModuleInfo
mi,ModuleInfo -> ModuleStatus
mstatus ModuleInfo
mi,ModuleInfo -> Options
mflags ModuleInfo
mi,ModuleInfo -> [(ModuleName, MInclude)]
mextend ModuleInfo
mi,ModuleInfo
-> Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
mwith ModuleInfo
mi,ModuleInfo -> [OpenSpec]
mopens ModuleInfo
mi,ModuleInfo -> [ModuleName]
mexdeps ModuleInfo
mi,ModuleInfo -> [Char]
msrc ModuleInfo
mi,ModuleInfo -> Maybe (Array SeqId Sequence)
mseqs ModuleInfo
mi,ModuleInfo -> Map Ident Info
jments ModuleInfo
mi)
get :: Get ModuleInfo
get = do (ModuleType
mtype,ModuleStatus
mstatus,Options
mflags,[(ModuleName, MInclude)]
mextend,Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
mwith,[OpenSpec]
mopens,[ModuleName]
med,[Char]
msrc,Maybe (Array SeqId Sequence)
mseqs,Map Ident Info
jments) <- Get
(ModuleType, ModuleStatus, Options, [(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char], Maybe (Array SeqId Sequence),
Map Ident Info)
forall t. Binary t => Get t
get
ModuleInfo -> Get ModuleInfo
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleType
-> ModuleStatus
-> Options
-> [(ModuleName, MInclude)]
-> Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
-> [OpenSpec]
-> [ModuleName]
-> [Char]
-> Maybe (Array SeqId Sequence)
-> Map Ident Info
-> ModuleInfo
ModInfo ModuleType
mtype ModuleStatus
mstatus Options
mflags [(ModuleName, MInclude)]
mextend Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
mwith [OpenSpec]
mopens [ModuleName]
med [Char]
msrc Maybe (Array SeqId Sequence)
mseqs Map Ident Info
jments)
instance Binary ModuleType where
put :: ModuleType -> Put
put ModuleType
MTAbstract = Word8 -> Put
putWord8 Word8
0
put ModuleType
MTResource = Word8 -> Put
putWord8 Word8
2
put (MTConcrete ModuleName
i) = Word8 -> Put
putWord8 Word8
3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ModuleName -> Put
forall t. Binary t => t -> Put
put ModuleName
i
put ModuleType
MTInterface = Word8 -> Put
putWord8 Word8
4
put (MTInstance (ModuleName, MInclude)
i) = Word8 -> Put
putWord8 Word8
5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (ModuleName, MInclude) -> Put
forall t. Binary t => t -> Put
put (ModuleName, MInclude)
i
get :: Get ModuleType
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> ModuleType -> Get ModuleType
forall (m :: * -> *) a. Monad m => a -> m a
return ModuleType
MTAbstract
Word8
2 -> ModuleType -> Get ModuleType
forall (m :: * -> *) a. Monad m => a -> m a
return ModuleType
MTResource
Word8
3 -> Get ModuleName
forall t. Binary t => Get t
get Get ModuleName -> (ModuleName -> Get ModuleType) -> Get ModuleType
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ModuleType -> Get ModuleType
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleType -> Get ModuleType)
-> (ModuleName -> ModuleType) -> ModuleName -> Get ModuleType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> ModuleType
MTConcrete
Word8
4 -> ModuleType -> Get ModuleType
forall (m :: * -> *) a. Monad m => a -> m a
return ModuleType
MTInterface
Word8
5 -> Get (ModuleName, MInclude)
forall t. Binary t => Get t
get Get (ModuleName, MInclude)
-> ((ModuleName, MInclude) -> Get ModuleType) -> Get ModuleType
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ModuleType -> Get ModuleType
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleType -> Get ModuleType)
-> ((ModuleName, MInclude) -> ModuleType)
-> (ModuleName, MInclude)
-> Get ModuleType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModuleName, MInclude) -> ModuleType
MTInstance
Word8
_ -> Get ModuleType
forall a. Get a
decodingError
instance Binary MInclude where
put :: MInclude -> Put
put MInclude
MIAll = Word8 -> Put
putWord8 Word8
0
put (MIOnly [Ident]
xs) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
xs
put (MIExcept [Ident]
xs) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Ident] -> Put
forall t. Binary t => t -> Put
put [Ident]
xs
get :: Get MInclude
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> MInclude -> Get MInclude
forall (m :: * -> *) a. Monad m => a -> m a
return MInclude
MIAll
Word8
1 -> ([Ident] -> MInclude) -> Get [Ident] -> Get MInclude
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Ident] -> MInclude
MIOnly Get [Ident]
forall t. Binary t => Get t
get
Word8
2 -> ([Ident] -> MInclude) -> Get [Ident] -> Get MInclude
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Ident] -> MInclude
MIExcept Get [Ident]
forall t. Binary t => Get t
get
Word8
_ -> Get MInclude
forall a. Get a
decodingError
instance Binary OpenSpec where
put :: OpenSpec -> Put
put (OSimple ModuleName
i) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ModuleName -> Put
forall t. Binary t => t -> Put
put ModuleName
i
put (OQualif ModuleName
i ModuleName
j) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (ModuleName, ModuleName) -> Put
forall t. Binary t => t -> Put
put (ModuleName
i,ModuleName
j)
get :: Get OpenSpec
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> Get ModuleName
forall t. Binary t => Get t
get Get ModuleName -> (ModuleName -> Get OpenSpec) -> Get OpenSpec
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= OpenSpec -> Get OpenSpec
forall (m :: * -> *) a. Monad m => a -> m a
return (OpenSpec -> Get OpenSpec)
-> (ModuleName -> OpenSpec) -> ModuleName -> Get OpenSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> OpenSpec
OSimple
Word8
1 -> Get (ModuleName, ModuleName)
forall t. Binary t => Get t
get Get (ModuleName, ModuleName)
-> ((ModuleName, ModuleName) -> Get OpenSpec) -> Get OpenSpec
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(ModuleName
i,ModuleName
j) -> OpenSpec -> Get OpenSpec
forall (m :: * -> *) a. Monad m => a -> m a
return (ModuleName -> ModuleName -> OpenSpec
OQualif ModuleName
i ModuleName
j)
Word8
_ -> Get OpenSpec
forall a. Get a
decodingError
instance Binary ModuleStatus where
put :: ModuleStatus -> Put
put ModuleStatus
MSComplete = Word8 -> Put
putWord8 Word8
0
put ModuleStatus
MSIncomplete = Word8 -> Put
putWord8 Word8
1
get :: Get ModuleStatus
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> ModuleStatus -> Get ModuleStatus
forall (m :: * -> *) a. Monad m => a -> m a
return ModuleStatus
MSComplete
Word8
1 -> ModuleStatus -> Get ModuleStatus
forall (m :: * -> *) a. Monad m => a -> m a
return ModuleStatus
MSIncomplete
Word8
_ -> Get ModuleStatus
forall a. Get a
decodingError
instance Binary Options where
put :: Options -> Put
put = [([Char], Literal)] -> Put
forall t. Binary t => t -> Put
put ([([Char], Literal)] -> Put)
-> (Options -> [([Char], Literal)]) -> Options -> Put
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Options -> [([Char], Literal)]
optionsGFO
get :: Get Options
get = do [([Char], Literal)]
opts <- Get [([Char], Literal)]
forall t. Binary t => Get t
get
case [[Char]] -> Err Options
forall (err :: * -> *). ErrorMonad err => [[Char]] -> err Options
parseModuleOptions [[Char]
"--" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
flag [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"=" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Literal -> [Char]
toString Literal
value | ([Char]
flag,Literal
value) <- [([Char], Literal)]
opts] of
Ok Options
x -> Options -> Get Options
forall (m :: * -> *) a. Monad m => a -> m a
return Options
x
Bad [Char]
msg -> [Char] -> Get Options
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
msg
where
toString :: Literal -> [Char]
toString (LStr [Char]
s) = [Char]
s
toString (LInt SeqId
n) = SeqId -> [Char]
forall a. Show a => a -> [Char]
show SeqId
n
toString (LFlt Double
d) = Double -> [Char]
forall a. Show a => a -> [Char]
show Double
d
instance Binary Production where
put :: Production -> Put
put (Production SeqId
res SeqId
funid [[SeqId]]
args) = (SeqId, SeqId, [[SeqId]]) -> Put
forall t. Binary t => t -> Put
put (SeqId
res,SeqId
funid,[[SeqId]]
args)
get :: Get Production
get = do SeqId
res <- Get SeqId
forall t. Binary t => Get t
get
SeqId
funid <- Get SeqId
forall t. Binary t => Get t
get
[[SeqId]]
args <- Get [[SeqId]]
forall t. Binary t => Get t
get
Production -> Get Production
forall (m :: * -> *) a. Monad m => a -> m a
return (SeqId -> SeqId -> [[SeqId]] -> Production
Production SeqId
res SeqId
funid [[SeqId]]
args)
instance Binary PMCFG where
put :: PMCFG -> Put
put (PMCFG [Production]
prods Array SeqId (UArray SeqId SeqId)
funs) = ([Production], Array SeqId (UArray SeqId SeqId)) -> Put
forall t. Binary t => t -> Put
put ([Production]
prods,Array SeqId (UArray SeqId SeqId)
funs)
get :: Get PMCFG
get = do [Production]
prods <- Get [Production]
forall t. Binary t => Get t
get
Array SeqId (UArray SeqId SeqId)
funs <- Get (Array SeqId (UArray SeqId SeqId))
forall t. Binary t => Get t
get
PMCFG -> Get PMCFG
forall (m :: * -> *) a. Monad m => a -> m a
return ([Production] -> Array SeqId (UArray SeqId SeqId) -> PMCFG
PMCFG [Production]
prods Array SeqId (UArray SeqId SeqId)
funs)
instance Binary Info where
put :: Info -> Put
put (AbsCat Maybe (L Context)
x) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Maybe (L Context) -> Put
forall t. Binary t => t -> Put
put Maybe (L Context)
x
put (AbsFun Maybe (L Type)
w Maybe SeqId
x Maybe [L Equation]
y Maybe Bool
z) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Maybe (L Type), Maybe SeqId, Maybe [L Equation], Maybe Bool)
-> Put
forall t. Binary t => t -> Put
put (Maybe (L Type)
w,Maybe SeqId
x,Maybe [L Equation]
y,Maybe Bool
z)
put (ResParam Maybe (L [Param])
x Maybe [Type]
y) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Maybe (L [Param]), Maybe [Type]) -> Put
forall t. Binary t => t -> Put
put (Maybe (L [Param])
x,Maybe [Type]
y)
put (ResValue L Type
x) = Word8 -> Put
putWord8 Word8
3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> L Type -> Put
forall t. Binary t => t -> Put
put L Type
x
put (ResOper Maybe (L Type)
x Maybe (L Type)
y) = Word8 -> Put
putWord8 Word8
4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Maybe (L Type), Maybe (L Type)) -> Put
forall t. Binary t => t -> Put
put (Maybe (L Type)
x,Maybe (L Type)
y)
put (ResOverload [ModuleName]
x [(L Type, L Type)]
y)= Word8 -> Put
putWord8 Word8
5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ([ModuleName], [(L Type, L Type)]) -> Put
forall t. Binary t => t -> Put
put ([ModuleName]
x,[(L Type, L Type)]
y)
put (CncCat Maybe (L Type)
v Maybe (L Type)
w Maybe (L Type)
x Maybe (L Type)
y Maybe PMCFG
z)=Word8 -> Put
putWord8 Word8
6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Maybe (L Type), Maybe (L Type), Maybe (L Type), Maybe (L Type),
Maybe PMCFG)
-> Put
forall t. Binary t => t -> Put
put (Maybe (L Type)
v,Maybe (L Type)
w,Maybe (L Type)
x,Maybe (L Type)
y,Maybe PMCFG
z)
put (CncFun Maybe (Ident, Context, Type)
w Maybe (L Type)
x Maybe (L Type)
y Maybe PMCFG
z) = Word8 -> Put
putWord8 Word8
7 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Maybe (Ident, Context, Type), Maybe (L Type), Maybe (L Type),
Maybe PMCFG)
-> Put
forall t. Binary t => t -> Put
put (Maybe (Ident, Context, Type)
w,Maybe (L Type)
x,Maybe (L Type)
y,Maybe PMCFG
z)
put (AnyInd Bool
x ModuleName
y) = Word8 -> Put
putWord8 Word8
8 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Bool, ModuleName) -> Put
forall t. Binary t => t -> Put
put (Bool
x,ModuleName
y)
get :: Get Info
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> Get (Maybe (L Context))
forall t. Binary t => Get t
get Get (Maybe (L Context))
-> (Maybe (L Context) -> Get Info) -> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe (L Context)
x -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (L Context) -> Info
AbsCat Maybe (L Context)
x)
Word8
1 -> Get (Maybe (L Type), Maybe SeqId, Maybe [L Equation], Maybe Bool)
forall t. Binary t => Get t
get Get (Maybe (L Type), Maybe SeqId, Maybe [L Equation], Maybe Bool)
-> ((Maybe (L Type), Maybe SeqId, Maybe [L Equation], Maybe Bool)
-> Get Info)
-> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Maybe (L Type)
w,Maybe SeqId
x,Maybe [L Equation]
y,Maybe Bool
z) -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (L Type)
-> Maybe SeqId -> Maybe [L Equation] -> Maybe Bool -> Info
AbsFun Maybe (L Type)
w Maybe SeqId
x Maybe [L Equation]
y Maybe Bool
z)
Word8
2 -> Get (Maybe (L [Param]), Maybe [Type])
forall t. Binary t => Get t
get Get (Maybe (L [Param]), Maybe [Type])
-> ((Maybe (L [Param]), Maybe [Type]) -> Get Info) -> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Maybe (L [Param])
x,Maybe [Type]
y) -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (L [Param]) -> Maybe [Type] -> Info
ResParam Maybe (L [Param])
x Maybe [Type]
y)
Word8
3 -> Get (L Type)
forall t. Binary t => Get t
get Get (L Type) -> (L Type -> Get Info) -> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \L Type
x -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (L Type -> Info
ResValue L Type
x)
Word8
4 -> Get (Maybe (L Type), Maybe (L Type))
forall t. Binary t => Get t
get Get (Maybe (L Type), Maybe (L Type))
-> ((Maybe (L Type), Maybe (L Type)) -> Get Info) -> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Maybe (L Type)
x,Maybe (L Type)
y) -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (L Type) -> Maybe (L Type) -> Info
ResOper Maybe (L Type)
x Maybe (L Type)
y)
Word8
5 -> Get ([ModuleName], [(L Type, L Type)])
forall t. Binary t => Get t
get Get ([ModuleName], [(L Type, L Type)])
-> (([ModuleName], [(L Type, L Type)]) -> Get Info) -> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \([ModuleName]
x,[(L Type, L Type)]
y) -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return ([ModuleName] -> [(L Type, L Type)] -> Info
ResOverload [ModuleName]
x [(L Type, L Type)]
y)
Word8
6 -> Get
(Maybe (L Type), Maybe (L Type), Maybe (L Type), Maybe (L Type),
Maybe PMCFG)
forall t. Binary t => Get t
get Get
(Maybe (L Type), Maybe (L Type), Maybe (L Type), Maybe (L Type),
Maybe PMCFG)
-> ((Maybe (L Type), Maybe (L Type), Maybe (L Type),
Maybe (L Type), Maybe PMCFG)
-> Get Info)
-> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Maybe (L Type)
v,Maybe (L Type)
w,Maybe (L Type)
x,Maybe (L Type)
y,Maybe PMCFG
z)->Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (L Type)
-> Maybe (L Type)
-> Maybe (L Type)
-> Maybe (L Type)
-> Maybe PMCFG
-> Info
CncCat Maybe (L Type)
v Maybe (L Type)
w Maybe (L Type)
x Maybe (L Type)
y Maybe PMCFG
z)
Word8
7 -> Get
(Maybe (Ident, Context, Type), Maybe (L Type), Maybe (L Type),
Maybe PMCFG)
forall t. Binary t => Get t
get Get
(Maybe (Ident, Context, Type), Maybe (L Type), Maybe (L Type),
Maybe PMCFG)
-> ((Maybe (Ident, Context, Type), Maybe (L Type), Maybe (L Type),
Maybe PMCFG)
-> Get Info)
-> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Maybe (Ident, Context, Type)
w,Maybe (L Type)
x,Maybe (L Type)
y,Maybe PMCFG
z) -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (Ident, Context, Type)
-> Maybe (L Type) -> Maybe (L Type) -> Maybe PMCFG -> Info
CncFun Maybe (Ident, Context, Type)
w Maybe (L Type)
x Maybe (L Type)
y Maybe PMCFG
z)
Word8
8 -> Get (Bool, ModuleName)
forall t. Binary t => Get t
get Get (Bool, ModuleName)
-> ((Bool, ModuleName) -> Get Info) -> Get Info
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Bool
x,ModuleName
y) -> Info -> Get Info
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> ModuleName -> Info
AnyInd Bool
x ModuleName
y)
Word8
_ -> Get Info
forall a. Get a
decodingError
instance Binary Location where
put :: Location -> Put
put Location
NoLoc = Word8 -> Put
putWord8 Word8
0
put (Local SeqId
x SeqId
y) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (SeqId, SeqId) -> Put
forall t. Binary t => t -> Put
put (SeqId
x,SeqId
y)
put (External [Char]
x Location
y) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ([Char], Location) -> Put
forall t. Binary t => t -> Put
put ([Char]
x,Location
y)
get :: Get Location
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> Location -> Get Location
forall (m :: * -> *) a. Monad m => a -> m a
return Location
NoLoc
Word8
1 -> Get (SeqId, SeqId)
forall t. Binary t => Get t
get Get (SeqId, SeqId)
-> ((SeqId, SeqId) -> Get Location) -> Get Location
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(SeqId
x,SeqId
y) -> Location -> Get Location
forall (m :: * -> *) a. Monad m => a -> m a
return (SeqId -> SeqId -> Location
Local SeqId
x SeqId
y)
Word8
2 -> Get ([Char], Location)
forall t. Binary t => Get t
get Get ([Char], Location)
-> (([Char], Location) -> Get Location) -> Get Location
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \([Char]
x,Location
y) -> Location -> Get Location
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char] -> Location -> Location
External [Char]
x Location
y)
instance Binary a => Binary (L a) where
put :: L a -> Put
put (L Location
x a
y) = (Location, a) -> Put
forall t. Binary t => t -> Put
put (Location
x,a
y)
get :: Get (L a)
get = Get (Location, a)
forall t. Binary t => Get t
get Get (Location, a) -> ((Location, a) -> Get (L a)) -> Get (L a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Location
x,a
y) -> L a -> Get (L a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Location -> a -> L a
forall a. Location -> a -> L a
L Location
x a
y)
instance Binary Term where
put :: Type -> Put
put (Vr Ident
x) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
x
put (Cn Ident
x) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
x
put (Con Ident
x) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
x
put (Sort Ident
x) = Word8 -> Put
putWord8 Word8
3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
x
put (EInt SeqId
x) = Word8 -> Put
putWord8 Word8
4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SeqId -> Put
forall t. Binary t => t -> Put
put SeqId
x
put (EFloat Double
x) = Word8 -> Put
putWord8 Word8
5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Double -> Put
forall t. Binary t => t -> Put
put Double
x
put (K [Char]
x) = Word8 -> Put
putWord8 Word8
6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
x
put (Type
Empty) = Word8 -> Put
putWord8 Word8
7
put (App Type
x Type
y) = Word8 -> Put
putWord8 Word8
8 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Type) -> Put
forall t. Binary t => t -> Put
put (Type
x,Type
y)
put (Abs BindType
x Ident
y Type
z) = Word8 -> Put
putWord8 Word8
9 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (BindType, Ident, Type) -> Put
forall t. Binary t => t -> Put
put (BindType
x,Ident
y,Type
z)
put (Meta SeqId
x) = Word8 -> Put
putWord8 Word8
10 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SeqId -> Put
forall t. Binary t => t -> Put
put SeqId
x
put (ImplArg Type
x) = Word8 -> Put
putWord8 Word8
11 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Type -> Put
forall t. Binary t => t -> Put
put Type
x
put (Prod BindType
w Ident
x Type
y Type
z)= Word8 -> Put
putWord8 Word8
12 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (BindType, Ident, Type, Type) -> Put
forall t. Binary t => t -> Put
put (BindType
w,Ident
x,Type
y,Type
z)
put (Typed Type
x Type
y) = Word8 -> Put
putWord8 Word8
13 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Type) -> Put
forall t. Binary t => t -> Put
put (Type
x,Type
y)
put (Example Type
x [Char]
y) = Word8 -> Put
putWord8 Word8
14 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, [Char]) -> Put
forall t. Binary t => t -> Put
put (Type
x,[Char]
y)
put (RecType [Labelling]
x) = Word8 -> Put
putWord8 Word8
15 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Labelling] -> Put
forall t. Binary t => t -> Put
put [Labelling]
x
put (R [Assign]
x) = Word8 -> Put
putWord8 Word8
16 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Assign] -> Put
forall t. Binary t => t -> Put
put [Assign]
x
put (P Type
x Label
y) = Word8 -> Put
putWord8 Word8
17 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Label) -> Put
forall t. Binary t => t -> Put
put (Type
x,Label
y)
put (ExtR Type
x Type
y) = Word8 -> Put
putWord8 Word8
18 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Type) -> Put
forall t. Binary t => t -> Put
put (Type
x,Type
y)
put (Table Type
x Type
y) = Word8 -> Put
putWord8 Word8
19 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Type) -> Put
forall t. Binary t => t -> Put
put (Type
x,Type
y)
put (T TInfo
x [Case]
y) = Word8 -> Put
putWord8 Word8
20 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (TInfo, [Case]) -> Put
forall t. Binary t => t -> Put
put (TInfo
x,[Case]
y)
put (V Type
x [Type]
y) = Word8 -> Put
putWord8 Word8
21 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, [Type]) -> Put
forall t. Binary t => t -> Put
put (Type
x,[Type]
y)
put (S Type
x Type
y) = Word8 -> Put
putWord8 Word8
22 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Type) -> Put
forall t. Binary t => t -> Put
put (Type
x,Type
y)
put (Let LocalDef
x Type
y) = Word8 -> Put
putWord8 Word8
23 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (LocalDef, Type) -> Put
forall t. Binary t => t -> Put
put (LocalDef
x,Type
y)
put (Q QIdent
x) = Word8 -> Put
putWord8 Word8
24 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QIdent -> Put
forall t. Binary t => t -> Put
put QIdent
x
put (QC QIdent
x) = Word8 -> Put
putWord8 Word8
25 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QIdent -> Put
forall t. Binary t => t -> Put
put QIdent
x
put (C Type
x Type
y) = Word8 -> Put
putWord8 Word8
26 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Type) -> Put
forall t. Binary t => t -> Put
put (Type
x,Type
y)
put (Glue Type
x Type
y) = Word8 -> Put
putWord8 Word8
27 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Type) -> Put
forall t. Binary t => t -> Put
put (Type
x,Type
y)
put (EPatt Patt
x) = Word8 -> Put
putWord8 Word8
28 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Patt -> Put
forall t. Binary t => t -> Put
put Patt
x
put (EPattType Type
x) = Word8 -> Put
putWord8 Word8
29 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Type -> Put
forall t. Binary t => t -> Put
put Type
x
put (ELincat Ident
x Type
y) = Word8 -> Put
putWord8 Word8
30 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Ident, Type) -> Put
forall t. Binary t => t -> Put
put (Ident
x,Type
y)
put (ELin Ident
x Type
y) = Word8 -> Put
putWord8 Word8
31 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Ident, Type) -> Put
forall t. Binary t => t -> Put
put (Ident
x,Type
y)
put (FV [Type]
x) = Word8 -> Put
putWord8 Word8
32 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Type] -> Put
forall t. Binary t => t -> Put
put [Type]
x
put (Alts Type
x [(Type, Type)]
y) = Word8 -> Put
putWord8 Word8
33 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, [(Type, Type)]) -> Put
forall t. Binary t => t -> Put
put (Type
x,[(Type, Type)]
y)
put (Strs [Type]
x) = Word8 -> Put
putWord8 Word8
34 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Type] -> Put
forall t. Binary t => t -> Put
put [Type]
x
put (Error [Char]
x) = Word8 -> Put
putWord8 Word8
35 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
x
get :: Get Type
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> Get Ident
forall t. Binary t => Get t
get Get Ident -> (Ident -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ident
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Type
Vr Ident
x)
Word8
1 -> Get Ident
forall t. Binary t => Get t
get Get Ident -> (Ident -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ident
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Type
Cn Ident
x)
Word8
2 -> Get Ident
forall t. Binary t => Get t
get Get Ident -> (Ident -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ident
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Type
Con Ident
x)
Word8
3 -> Get Ident
forall t. Binary t => Get t
get Get Ident -> (Ident -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ident
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Type
Sort Ident
x)
Word8
4 -> Get SeqId
forall t. Binary t => Get t
get Get SeqId -> (SeqId -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \SeqId
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (SeqId -> Type
EInt SeqId
x)
Word8
5 -> Get Double
forall t. Binary t => Get t
get Get Double -> (Double -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Double
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Double -> Type
EFloat Double
x)
Word8
6 -> Get [Char]
forall t. Binary t => Get t
get Get [Char] -> ([Char] -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Char]
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char] -> Type
K [Char]
x)
Word8
7 -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type
Empty)
Word8
8 -> Get (Type, Type)
forall t. Binary t => Get t
get Get (Type, Type) -> ((Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type -> Type
App Type
x Type
y)
Word8
9 -> Get (BindType, Ident, Type)
forall t. Binary t => Get t
get Get (BindType, Ident, Type)
-> ((BindType, Ident, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(BindType
x,Ident
y,Type
z) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (BindType -> Ident -> Type -> Type
Abs BindType
x Ident
y Type
z)
Word8
10 -> Get SeqId
forall t. Binary t => Get t
get Get SeqId -> (SeqId -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \SeqId
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (SeqId -> Type
Meta SeqId
x)
Word8
11 -> Get Type
forall t. Binary t => Get t
get Get Type -> (Type -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type
ImplArg Type
x)
Word8
12 -> Get (BindType, Ident, Type, Type)
forall t. Binary t => Get t
get Get (BindType, Ident, Type, Type)
-> ((BindType, Ident, Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(BindType
w,Ident
x,Type
y,Type
z)->Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (BindType -> Ident -> Type -> Type -> Type
Prod BindType
w Ident
x Type
y Type
z)
Word8
13 -> Get (Type, Type)
forall t. Binary t => Get t
get Get (Type, Type) -> ((Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type -> Type
Typed Type
x Type
y)
Word8
14 -> Get (Type, [Char])
forall t. Binary t => Get t
get Get (Type, [Char]) -> ((Type, [Char]) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,[Char]
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> [Char] -> Type
Example Type
x [Char]
y)
Word8
15 -> Get [Labelling]
forall t. Binary t => Get t
get Get [Labelling] -> ([Labelling] -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Labelling]
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return ([Labelling] -> Type
RecType [Labelling]
x)
Word8
16 -> Get [Assign]
forall t. Binary t => Get t
get Get [Assign] -> ([Assign] -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Assign]
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return ([Assign] -> Type
R [Assign]
x)
Word8
17 -> Get (Type, Label)
forall t. Binary t => Get t
get Get (Type, Label) -> ((Type, Label) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Label
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Label -> Type
P Type
x Label
y)
Word8
18 -> Get (Type, Type)
forall t. Binary t => Get t
get Get (Type, Type) -> ((Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type -> Type
ExtR Type
x Type
y)
Word8
19 -> Get (Type, Type)
forall t. Binary t => Get t
get Get (Type, Type) -> ((Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type -> Type
Table Type
x Type
y)
Word8
20 -> Get (TInfo, [Case])
forall t. Binary t => Get t
get Get (TInfo, [Case]) -> ((TInfo, [Case]) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(TInfo
x,[Case]
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (TInfo -> [Case] -> Type
T TInfo
x [Case]
y)
Word8
21 -> Get (Type, [Type])
forall t. Binary t => Get t
get Get (Type, [Type]) -> ((Type, [Type]) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,[Type]
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> [Type] -> Type
V Type
x [Type]
y)
Word8
22 -> Get (Type, Type)
forall t. Binary t => Get t
get Get (Type, Type) -> ((Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type -> Type
S Type
x Type
y)
Word8
23 -> Get (LocalDef, Type)
forall t. Binary t => Get t
get Get (LocalDef, Type) -> ((LocalDef, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(LocalDef
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (LocalDef -> Type -> Type
Let LocalDef
x Type
y)
Word8
24 -> Get QIdent
forall t. Binary t => Get t
get Get QIdent -> (QIdent -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \QIdent
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (QIdent -> Type
Q QIdent
x)
Word8
25 -> Get QIdent
forall t. Binary t => Get t
get Get QIdent -> (QIdent -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \QIdent
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (QIdent -> Type
QC QIdent
x)
Word8
26 -> Get (Type, Type)
forall t. Binary t => Get t
get Get (Type, Type) -> ((Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type -> Type
C Type
x Type
y)
Word8
27 -> Get (Type, Type)
forall t. Binary t => Get t
get Get (Type, Type) -> ((Type, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type -> Type
Glue Type
x Type
y)
Word8
28 -> Get Patt
forall t. Binary t => Get t
get Get Patt -> (Patt -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Patt
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt -> Type
EPatt Patt
x)
Word8
29 -> Get Type
forall t. Binary t => Get t
get Get Type -> (Type -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Type
EPattType Type
x)
Word8
30 -> Get (Ident, Type)
forall t. Binary t => Get t
get Get (Ident, Type) -> ((Ident, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Ident
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Type -> Type
ELincat Ident
x Type
y)
Word8
31 -> Get (Ident, Type)
forall t. Binary t => Get t
get Get (Ident, Type) -> ((Ident, Type) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Ident
x,Type
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Type -> Type
ELin Ident
x Type
y)
Word8
32 -> Get [Type]
forall t. Binary t => Get t
get Get [Type] -> ([Type] -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Type]
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return ([Type] -> Type
FV [Type]
x)
Word8
33 -> Get (Type, [(Type, Type)])
forall t. Binary t => Get t
get Get (Type, [(Type, Type)])
-> ((Type, [(Type, Type)]) -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,[(Type, Type)]
y) -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> [(Type, Type)] -> Type
Alts Type
x [(Type, Type)]
y)
Word8
34 -> Get [Type]
forall t. Binary t => Get t
get Get [Type] -> ([Type] -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Type]
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return ([Type] -> Type
Strs [Type]
x)
Word8
35 -> Get [Char]
forall t. Binary t => Get t
get Get [Char] -> ([Char] -> Get Type) -> Get Type
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Char]
x -> Type -> Get Type
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char] -> Type
Error [Char]
x)
Word8
_ -> Get Type
forall a. Get a
decodingError
instance Binary Patt where
put :: Patt -> Put
put (PC Ident
x [Patt]
y) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Ident, [Patt]) -> Put
forall t. Binary t => t -> Put
put (Ident
x,[Patt]
y)
put (PP QIdent
x [Patt]
y) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (QIdent, [Patt]) -> Put
forall t. Binary t => t -> Put
put (QIdent
x,[Patt]
y)
put (PV Ident
x) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
x
put (Patt
PW) = Word8 -> Put
putWord8 Word8
3
put (PR [(Label, Patt)]
x) = Word8 -> Put
putWord8 Word8
4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [(Label, Patt)] -> Put
forall t. Binary t => t -> Put
put [(Label, Patt)]
x
put (PString [Char]
x) = Word8 -> Put
putWord8 Word8
5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
x
put (PInt SeqId
x) = Word8 -> Put
putWord8 Word8
6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SeqId -> Put
forall t. Binary t => t -> Put
put SeqId
x
put (PFloat Double
x) = Word8 -> Put
putWord8 Word8
7 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Double -> Put
forall t. Binary t => t -> Put
put Double
x
put (PT Type
x Patt
y) = Word8 -> Put
putWord8 Word8
8 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Type, Patt) -> Put
forall t. Binary t => t -> Put
put (Type
x,Patt
y)
put (PAs Ident
x Patt
y) = Word8 -> Put
putWord8 Word8
10 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Ident, Patt) -> Put
forall t. Binary t => t -> Put
put (Ident
x,Patt
y)
put (PNeg Patt
x) = Word8 -> Put
putWord8 Word8
11 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Patt -> Put
forall t. Binary t => t -> Put
put Patt
x
put (PAlt Patt
x Patt
y) = Word8 -> Put
putWord8 Word8
12 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Patt, Patt) -> Put
forall t. Binary t => t -> Put
put (Patt
x,Patt
y)
put (PSeq Patt
x Patt
y) = Word8 -> Put
putWord8 Word8
13 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Patt, Patt) -> Put
forall t. Binary t => t -> Put
put (Patt
x,Patt
y)
put (PRep Patt
x) = Word8 -> Put
putWord8 Word8
14 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Patt -> Put
forall t. Binary t => t -> Put
put Patt
x
put (Patt
PChar) = Word8 -> Put
putWord8 Word8
15
put (PChars [Char]
x) = Word8 -> Put
putWord8 Word8
16 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
x
put (PMacro Ident
x) = Word8 -> Put
putWord8 Word8
17 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Ident -> Put
forall t. Binary t => t -> Put
put Ident
x
put (PM QIdent
x) = Word8 -> Put
putWord8 Word8
18 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> QIdent -> Put
forall t. Binary t => t -> Put
put QIdent
x
put (PTilde Type
x) = Word8 -> Put
putWord8 Word8
19 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Type -> Put
forall t. Binary t => t -> Put
put Type
x
put (PImplArg Patt
x) = Word8 -> Put
putWord8 Word8
20 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Patt -> Put
forall t. Binary t => t -> Put
put Patt
x
get :: Get Patt
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> Get (Ident, [Patt])
forall t. Binary t => Get t
get Get (Ident, [Patt]) -> ((Ident, [Patt]) -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Ident
x,[Patt]
y) -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> [Patt] -> Patt
PC Ident
x [Patt]
y)
Word8
1 -> Get (QIdent, [Patt])
forall t. Binary t => Get t
get Get (QIdent, [Patt]) -> ((QIdent, [Patt]) -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(QIdent
x,[Patt]
y) -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (QIdent -> [Patt] -> Patt
PP QIdent
x [Patt]
y)
Word8
2 -> Get Ident
forall t. Binary t => Get t
get Get Ident -> (Ident -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ident
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Patt
PV Ident
x)
Word8
3 -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt
PW)
Word8
4 -> Get [(Label, Patt)]
forall t. Binary t => Get t
get Get [(Label, Patt)] -> ([(Label, Patt)] -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[(Label, Patt)]
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return ([(Label, Patt)] -> Patt
PR [(Label, Patt)]
x)
Word8
5 -> Get [Char]
forall t. Binary t => Get t
get Get [Char] -> ([Char] -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Char]
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char] -> Patt
PString [Char]
x)
Word8
6 -> Get SeqId
forall t. Binary t => Get t
get Get SeqId -> (SeqId -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \SeqId
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (SeqId -> Patt
PInt SeqId
x)
Word8
7 -> Get Double
forall t. Binary t => Get t
get Get Double -> (Double -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Double
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Double -> Patt
PFloat Double
x)
Word8
8 -> Get (Type, Patt)
forall t. Binary t => Get t
get Get (Type, Patt) -> ((Type, Patt) -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Type
x,Patt
y) -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Patt -> Patt
PT Type
x Patt
y)
Word8
10 -> Get (Ident, Patt)
forall t. Binary t => Get t
get Get (Ident, Patt) -> ((Ident, Patt) -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Ident
x,Patt
y) -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Patt -> Patt
PAs Ident
x Patt
y)
Word8
11 -> Get Patt
forall t. Binary t => Get t
get Get Patt -> (Patt -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Patt
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt -> Patt
PNeg Patt
x)
Word8
12 -> Get (Patt, Patt)
forall t. Binary t => Get t
get Get (Patt, Patt) -> ((Patt, Patt) -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Patt
x,Patt
y) -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt -> Patt -> Patt
PAlt Patt
x Patt
y)
Word8
13 -> Get (Patt, Patt)
forall t. Binary t => Get t
get Get (Patt, Patt) -> ((Patt, Patt) -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Patt
x,Patt
y) -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt -> Patt -> Patt
PSeq Patt
x Patt
y)
Word8
14 -> Get Patt
forall t. Binary t => Get t
get Get Patt -> (Patt -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Patt
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt -> Patt
PRep Patt
x)
Word8
15 -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt
PChar)
Word8
16 -> Get [Char]
forall t. Binary t => Get t
get Get [Char] -> ([Char] -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Char]
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char] -> Patt
PChars [Char]
x)
Word8
17 -> Get Ident
forall t. Binary t => Get t
get Get Ident -> (Ident -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ident
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Patt
PMacro Ident
x)
Word8
18 -> Get QIdent
forall t. Binary t => Get t
get Get QIdent -> (QIdent -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \QIdent
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (QIdent -> Patt
PM QIdent
x)
Word8
19 -> Get Type
forall t. Binary t => Get t
get Get Type -> (Type -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Type -> Patt
PTilde Type
x)
Word8
20 -> Get Patt
forall t. Binary t => Get t
get Get Patt -> (Patt -> Get Patt) -> Get Patt
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Patt
x -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return (Patt -> Patt
PImplArg Patt
x)
Word8
_ -> Get Patt
forall a. Get a
decodingError
instance Binary TInfo where
put :: TInfo -> Put
put TInfo
TRaw = Word8 -> Put
putWord8 Word8
0
put (TTyped Type
t) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Type -> Put
forall t. Binary t => t -> Put
put Type
t
put (TComp Type
t) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Type -> Put
forall t. Binary t => t -> Put
put Type
t
put (TWild Type
t) = Word8 -> Put
putWord8 Word8
3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Type -> Put
forall t. Binary t => t -> Put
put Type
t
get :: Get TInfo
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> TInfo -> Get TInfo
forall (m :: * -> *) a. Monad m => a -> m a
return TInfo
TRaw
Word8
1 -> (Type -> TInfo) -> Get Type -> Get TInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Type -> TInfo
TTyped Get Type
forall t. Binary t => Get t
get
Word8
2 -> (Type -> TInfo) -> Get Type -> Get TInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Type -> TInfo
TComp Get Type
forall t. Binary t => Get t
get
Word8
3 -> (Type -> TInfo) -> Get Type -> Get TInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Type -> TInfo
TWild Get Type
forall t. Binary t => Get t
get
Word8
_ -> Get TInfo
forall a. Get a
decodingError
instance Binary Label where
put :: Label -> Put
put (LIdent RawIdent
bs) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> RawIdent -> Put
forall t. Binary t => t -> Put
put RawIdent
bs
put (LVar SeqId
i) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SeqId -> Put
forall t. Binary t => t -> Put
put SeqId
i
get :: Get Label
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> (RawIdent -> Label) -> Get RawIdent -> Get Label
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RawIdent -> Label
LIdent Get RawIdent
forall t. Binary t => Get t
get
Word8
1 -> (SeqId -> Label) -> Get SeqId -> Get Label
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap SeqId -> Label
LVar Get SeqId
forall t. Binary t => Get t
get
Word8
_ -> Get Label
forall a. Get a
decodingError
data VersionTagged a = Tagged {VersionTagged a -> a
unV::a} | WrongVersion
instance Binary a => Binary (VersionTagged a) where
put :: VersionTagged a -> Put
put (Tagged a
a) = ((Word8, Word8, Word8, Word8), a) -> Put
forall t. Binary t => t -> Put
put ((Word8, Word8, Word8, Word8)
gfoBinVersion,a
a)
get :: Get (VersionTagged a)
get = do (Word8, Word8, Word8, Word8)
ver <- Get (Word8, Word8, Word8, Word8)
forall t. Binary t => Get t
get
if (Word8, Word8, Word8, Word8)
ver(Word8, Word8, Word8, Word8)
-> (Word8, Word8, Word8, Word8) -> Bool
forall a. Eq a => a -> a -> Bool
==(Word8, Word8, Word8, Word8)
gfoBinVersion
then (a -> VersionTagged a) -> Get a -> Get (VersionTagged a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> VersionTagged a
forall a. a -> VersionTagged a
Tagged Get a
forall t. Binary t => Get t
get
else VersionTagged a -> Get (VersionTagged a)
forall (m :: * -> *) a. Monad m => a -> m a
return VersionTagged a
forall a. VersionTagged a
WrongVersion
instance Functor VersionTagged where
fmap :: (a -> b) -> VersionTagged a -> VersionTagged b
fmap a -> b
f (Tagged a
a) = b -> VersionTagged b
forall a. a -> VersionTagged a
Tagged (a -> b
f a
a)
fmap a -> b
f VersionTagged a
WrongVersion = VersionTagged b
forall a. VersionTagged a
WrongVersion
gfoBinVersion :: (Word8, Word8, Word8, Word8)
gfoBinVersion = (Word8
b1,Word8
b2,Word8
b3,Word8
b4)
where [Word8
b1,Word8
b2,Word8
b3,Word8
b4] = (Char -> Word8) -> [Char] -> [Word8]
forall a b. (a -> b) -> [a] -> [b]
map (SeqId -> Word8
forall a. Enum a => SeqId -> a
toEnum(SeqId -> Word8) -> (Char -> SeqId) -> Char -> Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Char -> SeqId
forall a. Enum a => a -> SeqId
fromEnum) [Char]
gfoVersion :: [Word8]
decodeModule :: MonadIO io => FilePath -> io SourceModule
decodeModule :: [Char] -> io Module
decodeModule [Char]
fpath = IO Module -> io Module
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Module -> io Module) -> IO Module -> io Module
forall a b. (a -> b) -> a -> b
$ VersionTagged Module -> IO Module
forall (m :: * -> *) a. MonadFail m => VersionTagged a -> m a
check (VersionTagged Module -> IO Module)
-> IO (VersionTagged Module) -> IO Module
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< [Char] -> IO (VersionTagged Module)
forall a. Binary a => [Char] -> IO a
decodeFile' [Char]
fpath
where
check :: VersionTagged a -> m a
check (Tagged a
m) = a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
m
check VersionTagged a
_ = [Char] -> m a
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
".gfo file version mismatch"
decodeModuleHeader :: MonadIO io => FilePath -> io (VersionTagged Module)
= IO (VersionTagged Module) -> io (VersionTagged Module)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (VersionTagged Module) -> io (VersionTagged Module))
-> ([Char] -> IO (VersionTagged Module))
-> [Char]
-> io (VersionTagged Module)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VersionTagged
(ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char])
-> VersionTagged Module)
-> IO
(VersionTagged
(ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char]))
-> IO (VersionTagged Module)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char])
-> Module)
-> VersionTagged
(ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char])
-> VersionTagged Module
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char])
-> Module
forall a.
(a, ModuleType, ModuleStatus, Options, [(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char])
-> (a, ModuleInfo)
conv) (IO
(VersionTagged
(ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char]))
-> IO (VersionTagged Module))
-> ([Char]
-> IO
(VersionTagged
(ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char])))
-> [Char]
-> IO (VersionTagged Module)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char]
-> IO
(VersionTagged
(ModuleName, ModuleType, ModuleStatus, Options,
[(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char]))
forall a. Binary a => [Char] -> IO a
decodeFile'
where
conv :: (a, ModuleType, ModuleStatus, Options, [(ModuleName, MInclude)],
Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)]),
[OpenSpec], [ModuleName], [Char])
-> (a, ModuleInfo)
conv (a
m,ModuleType
mtype,ModuleStatus
mstatus,Options
mflags,[(ModuleName, MInclude)]
mextend,Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
mwith,[OpenSpec]
mopens,[ModuleName]
med,[Char]
msrc) =
(a
m,ModuleType
-> ModuleStatus
-> Options
-> [(ModuleName, MInclude)]
-> Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
-> [OpenSpec]
-> [ModuleName]
-> [Char]
-> Maybe (Array SeqId Sequence)
-> Map Ident Info
-> ModuleInfo
ModInfo ModuleType
mtype ModuleStatus
mstatus Options
mflags [(ModuleName, MInclude)]
mextend Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
mwith [OpenSpec]
mopens [ModuleName]
med [Char]
msrc Maybe (Array SeqId Sequence)
forall a. Maybe a
Nothing Map Ident Info
forall k a. Map k a
Map.empty)
encodeModule :: MonadIO io => FilePath -> SourceModule -> io ()
encodeModule :: [Char] -> Module -> io ()
encodeModule [Char]
fpath Module
mo = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ [Char] -> VersionTagged Module -> IO ()
forall a. Binary a => [Char] -> a -> IO ()
encodeFile [Char]
fpath (Module -> VersionTagged Module
forall a. a -> VersionTagged a
Tagged Module
mo)
decodeFile' :: [Char] -> IO a
decodeFile' [Char]
fpath = [Char] -> IO a -> IO a
forall a. [Char] -> IO a -> IO a
addFPath [Char]
fpath ([Char] -> IO a
forall a. Binary a => [Char] -> IO a
decodeFile [Char]
fpath)
addFPath :: [Char] -> IO a -> IO a
addFPath [Char]
fpath IO a
m = IO a
m IO a -> (ErrorCall -> IO a) -> IO a
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`catch` ErrorCall -> IO a
forall a. ErrorCall -> IO a
handle
where
handle :: ErrorCall -> IO a
handle (ErrorCall [Char]
msg) = ErrorCall -> IO a
forall e a. Exception e => e -> IO a
throwIO ([Char] -> ErrorCall
ErrorCall ([Char]
fpath[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
": "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
msg))
decodingError :: Get a
decodingError = [Char] -> Get a
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"This file was compiled with different version of GF"