module PGF.Binary(putSplitAbs) where
import PGF.CId
import PGF.Data
import PGF.Optimize
import PGF.ByteCode
import qualified PGF.OldBinary as Old
import Data.Binary
import Data.Binary.Put
import Data.Binary.Get
import Data.Array.IArray
import qualified Data.Map as Map
import qualified Data.IntMap as IntMap
import Control.Monad
pgfMajorVersion, pgfMinorVersion :: Word16
version :: (Word16, Word16)
version@(Word16
pgfMajorVersion, Word16
pgfMinorVersion) = (Word16
2,Word16
1)
instance Binary PGF where
put :: PGF -> Put
put PGF
pgf = do Word16 -> Put
putWord16be Word16
pgfMajorVersion
Word16 -> Put
putWord16be Word16
pgfMinorVersion
Map CId Literal -> Put
forall t. Binary t => t -> Put
put (PGF -> Map CId Literal
gflags PGF
pgf)
(CId, Abstr) -> Put
forall t. Binary t => t -> Put
put (PGF -> CId
absname PGF
pgf, PGF -> Abstr
abstract PGF
pgf)
Map CId Concr -> Put
forall t. Binary t => t -> Put
put (PGF -> Map CId Concr
concretes PGF
pgf)
get :: Get PGF
get = do Word16
major<- Get Word16
getWord16be
Word16
minor <- Get Word16
getWord16be
let v :: (Word16, Word16)
v = (Word16
major,Word16
minor)
if Word16
majorWord16 -> Word16 -> Bool
forall a. Eq a => a -> a -> Bool
==Word16
pgfMajorVersion Bool -> Bool -> Bool
&& Word16
minorWord16 -> Word16 -> Bool
forall a. Ord a => a -> a -> Bool
<=Word16
pgfMinorVersion
then Get PGF
getPGF'
else if (Word16, Word16)
v(Word16, Word16) -> (Word16, Word16) -> Bool
forall a. Eq a => a -> a -> Bool
==(Word16, Word16)
Old.version
then Get PGF
Old.getPGF'
else String -> Get PGF
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Get PGF) -> String -> Get PGF
forall a b. (a -> b) -> a -> b
$ String
"Unsupported PGF version "String -> String -> String
forall a. [a] -> [a] -> [a]
++(Word16, Word16) -> String
forall a. Show a => a -> String
show (Word16
major,Word16
minor)
getPGF' :: Get PGF
getPGF'=do Map CId Literal
gflags <- Get (Map CId Literal)
forall t. Binary t => Get t
get
(CId
absname,Abstr
abstract) <- Get (CId, Abstr)
forall t. Binary t => Get t
get
Map CId Concr
concretes <- Get (Map CId Concr)
forall t. Binary t => Get t
get
PGF -> Get PGF
forall (m :: * -> *) a. Monad m => a -> m a
return (PGF -> Get PGF) -> PGF -> Get PGF
forall a b. (a -> b) -> a -> b
$ PGF -> PGF
updateProductionIndices (PGF -> PGF) -> PGF -> PGF
forall a b. (a -> b) -> a -> b
$
(PGF :: Map CId Literal -> CId -> Abstr -> Map CId Concr -> PGF
PGF{ gflags :: Map CId Literal
gflags=Map CId Literal
gflags
, absname :: CId
absname=CId
absname, abstract :: Abstr
abstract=Abstr
abstract
, concretes :: Map CId Concr
concretes=Map CId Concr
concretes
})
instance Binary CId where
put :: CId -> Put
put (CId ByteString
bs) = ByteString -> Put
forall t. Binary t => t -> Put
put ByteString
bs
get :: Get CId
get = (ByteString -> CId) -> Get ByteString -> Get CId
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ByteString -> CId
CId Get ByteString
forall t. Binary t => Get t
get
instance Binary Abstr where
put :: Abstr -> Put
put Abstr
abs = do Map CId Literal -> Put
forall t. Binary t => t -> Put
put (Abstr -> Map CId Literal
aflags Abstr
abs)
Map CId (Type, Int, Maybe [Equation], Double) -> Put
forall t. Binary t => t -> Put
put (((Type, Int, Maybe ([Equation], [[Instr]]), Double)
-> (Type, Int, Maybe [Equation], Double))
-> Map CId (Type, Int, Maybe ([Equation], [[Instr]]), Double)
-> Map CId (Type, Int, Maybe [Equation], Double)
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (\(Type
ty,Int
arity,Maybe ([Equation], [[Instr]])
mb_eq,Double
prob) -> (Type
ty,Int
arity,(([Equation], [[Instr]]) -> [Equation])
-> Maybe ([Equation], [[Instr]]) -> Maybe [Equation]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Equation], [[Instr]]) -> [Equation]
forall a b. (a, b) -> a
fst Maybe ([Equation], [[Instr]])
mb_eq,Double
prob)) (Abstr -> Map CId (Type, Int, Maybe ([Equation], [[Instr]]), Double)
funs Abstr
abs))
Map CId ([Hypo], [(Double, CId)], Double) -> Put
forall t. Binary t => t -> Put
put (Abstr -> Map CId ([Hypo], [(Double, CId)], Double)
cats Abstr
abs)
get :: Get Abstr
get = do Map CId Literal
aflags <- Get (Map CId Literal)
forall t. Binary t => Get t
get
Map CId (Type, Int, Maybe [Equation], Double)
funs <- Get (Map CId (Type, Int, Maybe [Equation], Double))
forall t. Binary t => Get t
get
Map CId ([Hypo], [(Double, CId)], Double)
cats <- Get (Map CId ([Hypo], [(Double, CId)], Double))
forall t. Binary t => Get t
get
Abstr -> Get Abstr
forall (m :: * -> *) a. Monad m => a -> m a
return (Abstr :: Map CId Literal
-> Map CId (Type, Int, Maybe ([Equation], [[Instr]]), Double)
-> Map CId ([Hypo], [(Double, CId)], Double)
-> Abstr
Abstr{ aflags :: Map CId Literal
aflags=Map CId Literal
aflags
, funs :: Map CId (Type, Int, Maybe ([Equation], [[Instr]]), Double)
funs=((Type, Int, Maybe [Equation], Double)
-> (Type, Int, Maybe ([Equation], [[Instr]]), Double))
-> Map CId (Type, Int, Maybe [Equation], Double)
-> Map CId (Type, Int, Maybe ([Equation], [[Instr]]), Double)
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (\(Type
ty,Int
arity,Maybe [Equation]
mb_eq,Double
prob) -> (Type
ty,Int
arity,([Equation] -> ([Equation], [[Instr]]))
-> Maybe [Equation] -> Maybe ([Equation], [[Instr]])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\[Equation]
eq -> ([Equation]
eq,[])) Maybe [Equation]
mb_eq,Double
prob)) Map CId (Type, Int, Maybe [Equation], Double)
funs
, cats :: Map CId ([Hypo], [(Double, CId)], Double)
cats=Map CId ([Hypo], [(Double, CId)], Double)
cats
})
putSplitAbs :: PGF -> Put
putSplitAbs :: PGF -> Put
putSplitAbs PGF
pgf = do
Word16 -> Put
putWord16be Word16
pgfMajorVersion
Word16 -> Put
putWord16be Word16
pgfMinorVersion
Map CId Literal -> Put
forall t. Binary t => t -> Put
put (CId -> Literal -> Map CId Literal -> Map CId Literal
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert (String -> CId
mkCId String
"split") (String -> Literal
LStr String
"true") (PGF -> Map CId Literal
gflags PGF
pgf))
(CId, Abstr) -> Put
forall t. Binary t => t -> Put
put (PGF -> CId
absname PGF
pgf, PGF -> Abstr
abstract PGF
pgf)
[(CId, Map CId Literal)] -> Put
forall t. Binary t => t -> Put
put [(CId
name,Concr -> Map CId Literal
cflags Concr
cnc) | (CId
name,Concr
cnc) <- Map CId Concr -> [(CId, Concr)]
forall k a. Map k a -> [(k, a)]
Map.toList (PGF -> Map CId Concr
concretes PGF
pgf)]
instance Binary Concr where
put :: Concr -> Put
put Concr
cnc = do Map CId Literal -> Put
forall t. Binary t => t -> Put
put (Concr -> Map CId Literal
cflags Concr
cnc)
Map CId String -> Put
forall t. Binary t => t -> Put
put (Concr -> Map CId String
printnames Concr
cnc)
Array Int (Array Int Symbol) -> Put
forall e (a1 :: * -> * -> *) (a2 :: * -> * -> *).
(Binary e, IArray a1 (a2 Int e), IArray a2 e) =>
a1 Int (a2 Int e) -> Put
putArray2 (Concr -> Array Int (Array Int Symbol)
sequences Concr
cnc)
Array Int CncFun -> Put
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
a Int e -> Put
putArray (Concr -> Array Int CncFun
cncfuns Concr
cnc)
IntMap [Int] -> Put
forall t. Binary t => t -> Put
put (Concr -> IntMap [Int]
lindefs Concr
cnc)
IntMap [Int] -> Put
forall t. Binary t => t -> Put
put (Concr -> IntMap [Int]
linrefs Concr
cnc)
IntMap (Set Production) -> Put
forall t. Binary t => t -> Put
put (Concr -> IntMap (Set Production)
productions Concr
cnc)
Map CId CncCat -> Put
forall t. Binary t => t -> Put
put (Concr -> Map CId CncCat
cnccats Concr
cnc)
Int -> Put
forall t. Binary t => t -> Put
put (Concr -> Int
totalCats Concr
cnc)
get :: Get Concr
get = do Map CId Literal
cflags <- Get (Map CId Literal)
forall t. Binary t => Get t
get
Map CId String
printnames <- Get (Map CId String)
forall t. Binary t => Get t
get
Array Int (Array Int Symbol)
sequences <- Get (Array Int (Array Int Symbol))
forall e (a1 :: * -> * -> *) (a2 :: * -> * -> *).
(Binary e, IArray a1 (a2 Int e), IArray a2 e) =>
Get (a1 Int (a2 Int e))
getArray2
Array Int CncFun
cncfuns <- Get (Array Int CncFun)
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
Get (a Int e)
getArray
IntMap [Int]
lindefs <- Get (IntMap [Int])
forall t. Binary t => Get t
get
IntMap [Int]
linrefs <- Get (IntMap [Int])
forall t. Binary t => Get t
get
IntMap (Set Production)
productions <- Get (IntMap (Set Production))
forall t. Binary t => Get t
get
Map CId CncCat
cnccats <- Get (Map CId CncCat)
forall t. Binary t => Get t
get
Int
totalCats <- Get Int
forall t. Binary t => Get t
get
Concr -> Get Concr
forall (m :: * -> *) a. Monad m => a -> m a
return (Concr :: Map CId Literal
-> Map CId String
-> Array Int CncFun
-> IntMap [Int]
-> IntMap [Int]
-> Array Int (Array Int Symbol)
-> IntMap (Set Production)
-> IntMap (Set Production)
-> Map CId (IntMap (Set Production))
-> Map CId CncCat
-> IntMap (IntMap (TrieMap String IntSet))
-> Int
-> Concr
Concr{ cflags :: Map CId Literal
cflags=Map CId Literal
cflags, printnames :: Map CId String
printnames=Map CId String
printnames
, sequences :: Array Int (Array Int Symbol)
sequences=Array Int (Array Int Symbol)
sequences, cncfuns :: Array Int CncFun
cncfuns=Array Int CncFun
cncfuns
, lindefs :: IntMap [Int]
lindefs=IntMap [Int]
lindefs, linrefs :: IntMap [Int]
linrefs=IntMap [Int]
linrefs
, productions :: IntMap (Set Production)
productions=IntMap (Set Production)
productions
, pproductions :: IntMap (Set Production)
pproductions = IntMap (Set Production)
forall a. IntMap a
IntMap.empty
, lproductions :: Map CId (IntMap (Set Production))
lproductions = Map CId (IntMap (Set Production))
forall k a. Map k a
Map.empty
, lexicon :: IntMap (IntMap (TrieMap String IntSet))
lexicon = IntMap (IntMap (TrieMap String IntSet))
forall a. IntMap a
IntMap.empty
, cnccats :: Map CId CncCat
cnccats=Map CId CncCat
cnccats, totalCats :: Int
totalCats=Int
totalCats
})
instance Binary Expr where
put :: Expr -> Put
put (EAbs BindType
b CId
x Expr
exp) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (BindType, CId, Expr) -> Put
forall t. Binary t => t -> Put
put (BindType
b,CId
x,Expr
exp)
put (EApp Expr
e1 Expr
e2) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Expr, Expr) -> Put
forall t. Binary t => t -> Put
put (Expr
e1,Expr
e2)
put (ELit Literal
l) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Literal -> Put
forall t. Binary t => t -> Put
put Literal
l
put (EMeta Int
i) = Word8 -> Put
putWord8 Word8
3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
i
put (EFun CId
f) = Word8 -> Put
putWord8 Word8
4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
f
put (EVar Int
i) = Word8 -> Put
putWord8 Word8
5 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
i
put (ETyped Expr
e Type
ty) = Word8 -> Put
putWord8 Word8
6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Expr, Type) -> Put
forall t. Binary t => t -> Put
put (Expr
e,Type
ty)
put (EImplArg Expr
e) = Word8 -> Put
putWord8 Word8
7 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expr -> Put
forall t. Binary t => t -> Put
put Expr
e
get :: Get Expr
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> (BindType -> CId -> Expr -> Expr)
-> Get BindType -> Get CId -> Get Expr -> Get Expr
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 BindType -> CId -> Expr -> Expr
EAbs Get BindType
forall t. Binary t => Get t
get Get CId
forall t. Binary t => Get t
get Get Expr
forall t. Binary t => Get t
get
Word8
1 -> (Expr -> Expr -> Expr) -> Get Expr -> Get Expr -> Get Expr
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Expr -> Expr -> Expr
EApp Get Expr
forall t. Binary t => Get t
get Get Expr
forall t. Binary t => Get t
get
Word8
2 -> (Literal -> Expr) -> Get Literal -> Get Expr
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Literal -> Expr
ELit Get Literal
forall t. Binary t => Get t
get
Word8
3 -> (Int -> Expr) -> Get Int -> Get Expr
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Int -> Expr
EMeta Get Int
forall t. Binary t => Get t
get
Word8
4 -> (CId -> Expr) -> Get CId -> Get Expr
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CId -> Expr
EFun Get CId
forall t. Binary t => Get t
get
Word8
5 -> (Int -> Expr) -> Get Int -> Get Expr
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Int -> Expr
EVar Get Int
forall t. Binary t => Get t
get
Word8
6 -> (Expr -> Type -> Expr) -> Get Expr -> Get Type -> Get Expr
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Expr -> Type -> Expr
ETyped Get Expr
forall t. Binary t => Get t
get Get Type
forall t. Binary t => Get t
get
Word8
7 -> (Expr -> Expr) -> Get Expr -> Get Expr
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Expr -> Expr
EImplArg Get Expr
forall t. Binary t => Get t
get
Word8
_ -> Get Expr
forall a. Get a
decodingError
instance Binary Patt where
put :: Patt -> Put
put (PApp CId
f [Patt]
ps) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (CId, [Patt]) -> Put
forall t. Binary t => t -> Put
put (CId
f,[Patt]
ps)
put (PVar CId
x) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
x
put (PAs CId
x Patt
p) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (CId, Patt) -> Put
forall t. Binary t => t -> Put
put (CId
x,Patt
p)
put Patt
PWild = Word8 -> Put
putWord8 Word8
3
put (PLit Literal
l) = Word8 -> Put
putWord8 Word8
4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Literal -> Put
forall t. Binary t => t -> Put
put Literal
l
put (PImplArg Patt
p) = Word8 -> Put
putWord8 Word8
5 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
p
put (PTilde Expr
p) = Word8 -> Put
putWord8 Word8
6 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Expr -> Put
forall t. Binary t => t -> Put
put Expr
p
get :: Get Patt
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> (CId -> [Patt] -> Patt) -> Get CId -> Get [Patt] -> Get Patt
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 CId -> [Patt] -> Patt
PApp Get CId
forall t. Binary t => Get t
get Get [Patt]
forall t. Binary t => Get t
get
Word8
1 -> (CId -> Patt) -> Get CId -> Get Patt
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CId -> Patt
PVar Get CId
forall t. Binary t => Get t
get
Word8
2 -> (CId -> Patt -> Patt) -> Get CId -> Get Patt -> Get Patt
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 CId -> Patt -> Patt
PAs Get CId
forall t. Binary t => Get t
get Get Patt
forall t. Binary t => Get t
get
Word8
3 -> Patt -> Get Patt
forall (m :: * -> *) a. Monad m => a -> m a
return Patt
PWild
Word8
4 -> (Literal -> Patt) -> Get Literal -> Get Patt
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Literal -> Patt
PLit Get Literal
forall t. Binary t => Get t
get
Word8
5 -> (Patt -> Patt) -> Get Patt -> Get Patt
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Patt -> Patt
PImplArg Get Patt
forall t. Binary t => Get t
get
Word8
6 -> (Expr -> Patt) -> Get Expr -> Get Patt
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Expr -> Patt
PTilde Get Expr
forall t. Binary t => Get t
get
Word8
_ -> Get Patt
forall a. Get a
decodingError
instance Binary Equation where
put :: Equation -> Put
put (Equ [Patt]
ps Expr
e) = ([Patt], Expr) -> Put
forall t. Binary t => t -> Put
put ([Patt]
ps,Expr
e)
get :: Get Equation
get = ([Patt] -> Expr -> Equation)
-> Get [Patt] -> Get Expr -> Get Equation
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 [Patt] -> Expr -> Equation
Equ Get [Patt]
forall t. Binary t => Get t
get Get Expr
forall t. Binary t => Get t
get
instance Binary Instr where
put :: Instr -> Put
put (CHECK_ARGS Int
n) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (CASE CId
id Int
l) = Word8 -> Put
putWord8 Word8
4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (CId, Int) -> Put
forall t. Binary t => t -> Put
put (CId
id,Int
l)
put (CASE_LIT (LInt Int
n) Int
l) = Word8 -> Put
putWord8 Word8
8 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
n,Int
l)
put (CASE_LIT (LStr String
s) Int
l) = Word8 -> Put
putWord8 Word8
9 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (String, Int) -> Put
forall t. Binary t => t -> Put
put (String
s,Int
l)
put (CASE_LIT (LFlt Double
d) Int
l) = Word8 -> Put
putWord8 Word8
10 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Double, Int) -> Put
forall t. Binary t => t -> Put
put (Double
d,Int
l)
put (SAVE Int
n) = Word8 -> Put
putWord8 Word8
12 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (ALLOC Int
n) = Word8 -> Put
putWord8 Word8
16 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (PUT_CONSTR CId
id) = Word8 -> Put
putWord8 Word8
20 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
id
put (PUT_CLOSURE Int
l) = Word8 -> Put
putWord8 Word8
24 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
l
put (PUT_LIT (LInt Int
n)) = Word8 -> Put
putWord8 Word8
28 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (PUT_LIT (LStr String
s)) = Word8 -> Put
putWord8 Word8
29 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> Put
forall t. Binary t => t -> Put
put String
s
put (PUT_LIT (LFlt Double
d)) = Word8 -> Put
putWord8 Word8
30 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
d
put (SET (HEAP Int
n)) = Word8 -> Put
putWord8 Word8
32 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (SET (ARG_VAR Int
n)) = Word8 -> Put
putWord8 Word8
33 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (SET (FREE_VAR Int
n)) = Word8 -> Put
putWord8 Word8
34 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (SET (GLOBAL CId
id)) = Word8 -> Put
putWord8 Word8
35 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
id
put (Instr
SET_PAD ) = Word8 -> Put
putWord8 Word8
36
put (Instr
PUSH_FRAME ) = Word8 -> Put
putWord8 Word8
40
put (PUSH (HEAP Int
n)) = Word8 -> Put
putWord8 Word8
44 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (PUSH (ARG_VAR Int
n)) = Word8 -> Put
putWord8 Word8
45 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (PUSH (FREE_VAR Int
n)) = Word8 -> Put
putWord8 Word8
46 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (PUSH (GLOBAL CId
id)) = Word8 -> Put
putWord8 Word8
47 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
id
put (TUCK (HEAP Int
n) Int
i) = Word8 -> Put
putWord8 Word8
48 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
n,Int
i)
put (TUCK (ARG_VAR Int
n) Int
i) = Word8 -> Put
putWord8 Word8
49 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
n,Int
i)
put (TUCK (FREE_VAR Int
n) Int
i) = Word8 -> Put
putWord8 Word8
50 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
n,Int
i)
put (TUCK (GLOBAL CId
id) Int
i) = Word8 -> Put
putWord8 Word8
51 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (CId, Int) -> Put
forall t. Binary t => t -> Put
put (CId
id,Int
i)
put (EVAL (HEAP Int
n) TailInfo
RecCall) = Word8 -> Put
putWord8 Word8
52 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (EVAL (ARG_VAR Int
n) TailInfo
RecCall) = Word8 -> Put
putWord8 Word8
53 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (EVAL (FREE_VAR Int
n) TailInfo
RecCall) = Word8 -> Put
putWord8 Word8
54 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (EVAL (GLOBAL CId
id) TailInfo
RecCall) = Word8 -> Put
putWord8 Word8
55 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
id
put (EVAL (HEAP Int
n) (TailCall Int
a)) = Word8 -> Put
putWord8 Word8
56 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
a
put (EVAL (ARG_VAR Int
n) (TailCall Int
a)) = Word8 -> Put
putWord8 Word8
57 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
a
put (EVAL (FREE_VAR Int
n) (TailCall Int
a)) = Word8 -> Put
putWord8 Word8
58 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
a
put (EVAL (GLOBAL CId
id) (TailCall Int
a)) = Word8 -> Put
putWord8 Word8
59 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
id Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
a
put (EVAL (HEAP Int
n) TailInfo
UpdateCall) = Word8 -> Put
putWord8 Word8
60 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (EVAL (ARG_VAR Int
n) TailInfo
UpdateCall) = Word8 -> Put
putWord8 Word8
61 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (EVAL (FREE_VAR Int
n) TailInfo
UpdateCall) = Word8 -> Put
putWord8 Word8
62 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (EVAL (GLOBAL CId
id) TailInfo
UpdateCall) = Word8 -> Put
putWord8 Word8
63 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CId -> Put
forall t. Binary t => t -> Put
put CId
id
put (DROP Int
n ) = Word8 -> Put
putWord8 Word8
64 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (JUMP Int
l ) = Word8 -> Put
putWord8 Word8
68 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
l
put (Instr
FAIL ) = Word8 -> Put
putWord8 Word8
72
put (PUSH_ACCUM (LInt Int
n)) = Word8 -> Put
putWord8 Word8
76 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
n
put (PUSH_ACCUM (LStr String
s)) = Word8 -> Put
putWord8 Word8
77 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> Put
forall t. Binary t => t -> Put
put String
s
put (PUSH_ACCUM (LFlt Double
d)) = Word8 -> Put
putWord8 Word8
78 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
d
put (Instr
POP_ACCUM ) = Word8 -> Put
putWord8 Word8
80
put (Instr
ADD ) = Word8 -> Put
putWord8 Word8
84
get :: Get Instr
get = String -> Get Instr
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Missing implementation for ‘get’ in the instance declaration for ‘Binary Instr’"
instance Binary Type where
put :: Type -> Put
put (DTyp [Hypo]
hypos CId
cat [Expr]
exps) = ([Hypo], CId, [Expr]) -> Put
forall t. Binary t => t -> Put
put ([Hypo]
hypos,CId
cat,[Expr]
exps)
get :: Get Type
get = ([Hypo] -> CId -> [Expr] -> Type)
-> Get [Hypo] -> Get CId -> Get [Expr] -> Get Type
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 [Hypo] -> CId -> [Expr] -> Type
DTyp Get [Hypo]
forall t. Binary t => Get t
get Get CId
forall t. Binary t => Get t
get Get [Expr]
forall t. Binary t => Get t
get
instance Binary BindType where
put :: BindType -> Put
put BindType
Explicit = Word8 -> Put
putWord8 Word8
0
put BindType
Implicit = Word8 -> Put
putWord8 Word8
1
get :: Get BindType
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> BindType -> Get BindType
forall (m :: * -> *) a. Monad m => a -> m a
return BindType
Explicit
Word8
1 -> BindType -> Get BindType
forall (m :: * -> *) a. Monad m => a -> m a
return BindType
Implicit
Word8
_ -> Get BindType
forall a. Get a
decodingError
instance Binary CncFun where
put :: CncFun -> Put
put (CncFun CId
fun UArray Int Int
lins) = CId -> Put
forall t. Binary t => t -> Put
put CId
fun Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> UArray Int Int -> Put
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
a Int e -> Put
putArray UArray Int Int
lins
get :: Get CncFun
get = (CId -> UArray Int Int -> CncFun)
-> Get CId -> Get (UArray Int Int) -> Get CncFun
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 CId -> UArray Int Int -> CncFun
CncFun Get CId
forall t. Binary t => Get t
get Get (UArray Int Int)
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
Get (a Int e)
getArray
instance Binary CncCat where
put :: CncCat -> Put
put (CncCat Int
s Int
e Array Int String
labels) = do (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
s,Int
e)
Array Int String -> Put
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
a Int e -> Put
putArray Array Int String
labels
get :: Get CncCat
get = (Int -> Int -> Array Int String -> CncCat)
-> Get Int -> Get Int -> Get (Array Int String) -> Get CncCat
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 Int -> Int -> Array Int String -> CncCat
CncCat Get Int
forall t. Binary t => Get t
get Get Int
forall t. Binary t => Get t
get Get (Array Int String)
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
Get (a Int e)
getArray
instance Binary Symbol where
put :: Symbol -> Put
put (SymCat Int
n Int
l) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
n,Int
l)
put (SymLit Int
n Int
l) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
n,Int
l)
put (SymVar Int
n Int
l) = Word8 -> Put
putWord8 Word8
2 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, Int) -> Put
forall t. Binary t => t -> Put
put (Int
n,Int
l)
put (SymKS String
ts) = Word8 -> Put
putWord8 Word8
3 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> Put
forall t. Binary t => t -> Put
put String
ts
put (SymKP [Symbol]
d [([Symbol], [String])]
vs) = Word8 -> Put
putWord8 Word8
4 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ([Symbol], [([Symbol], [String])]) -> Put
forall t. Binary t => t -> Put
put ([Symbol]
d,[([Symbol], [String])]
vs)
put Symbol
SymBIND = Word8 -> Put
putWord8 Word8
5
put Symbol
SymSOFT_BIND = Word8 -> Put
putWord8 Word8
6
put Symbol
SymNE = Word8 -> Put
putWord8 Word8
7
put Symbol
SymSOFT_SPACE = Word8 -> Put
putWord8 Word8
8
put Symbol
SymCAPIT = Word8 -> Put
putWord8 Word8
9
put Symbol
SymALL_CAPIT = Word8 -> Put
putWord8 Word8
10
get :: Get Symbol
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> (Int -> Int -> Symbol) -> Get Int -> Get Int -> Get Symbol
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Int -> Int -> Symbol
SymCat Get Int
forall t. Binary t => Get t
get Get Int
forall t. Binary t => Get t
get
Word8
1 -> (Int -> Int -> Symbol) -> Get Int -> Get Int -> Get Symbol
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Int -> Int -> Symbol
SymLit Get Int
forall t. Binary t => Get t
get Get Int
forall t. Binary t => Get t
get
Word8
2 -> (Int -> Int -> Symbol) -> Get Int -> Get Int -> Get Symbol
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Int -> Int -> Symbol
SymVar Get Int
forall t. Binary t => Get t
get Get Int
forall t. Binary t => Get t
get
Word8
3 -> (String -> Symbol) -> Get String -> Get Symbol
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM String -> Symbol
SymKS Get String
forall t. Binary t => Get t
get
Word8
4 -> ([Symbol] -> [([Symbol], [String])] -> Symbol)
-> Get [Symbol] -> Get [([Symbol], [String])] -> Get Symbol
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (\[Symbol]
d [([Symbol], [String])]
vs -> [Symbol] -> [([Symbol], [String])] -> Symbol
SymKP [Symbol]
d [([Symbol], [String])]
vs) Get [Symbol]
forall t. Binary t => Get t
get Get [([Symbol], [String])]
forall t. Binary t => Get t
get
Word8
5 -> Symbol -> Get Symbol
forall (m :: * -> *) a. Monad m => a -> m a
return Symbol
SymBIND
Word8
6 -> Symbol -> Get Symbol
forall (m :: * -> *) a. Monad m => a -> m a
return Symbol
SymSOFT_BIND
Word8
7 -> Symbol -> Get Symbol
forall (m :: * -> *) a. Monad m => a -> m a
return Symbol
SymNE
Word8
8 -> Symbol -> Get Symbol
forall (m :: * -> *) a. Monad m => a -> m a
return Symbol
SymSOFT_SPACE
Word8
9 -> Symbol -> Get Symbol
forall (m :: * -> *) a. Monad m => a -> m a
return Symbol
SymCAPIT
Word8
10-> Symbol -> Get Symbol
forall (m :: * -> *) a. Monad m => a -> m a
return Symbol
SymALL_CAPIT
Word8
_ -> Get Symbol
forall a. Get a
decodingError
instance Binary PArg where
put :: PArg -> Put
put (PArg [(Int, Int)]
hypos Int
fid) = ([Int], Int) -> Put
forall t. Binary t => t -> Put
put (((Int, Int) -> Int) -> [(Int, Int)] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map (Int, Int) -> Int
forall a b. (a, b) -> b
snd [(Int, Int)]
hypos,Int
fid)
get :: Get PArg
get = Get ([Int], Int)
forall t. Binary t => Get t
get Get ([Int], Int) -> (([Int], Int) -> Get PArg) -> Get PArg
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \([Int]
hypos,Int
fid) -> PArg -> Get PArg
forall (m :: * -> *) a. Monad m => a -> m a
return ([(Int, Int)] -> Int -> PArg
PArg ([Int] -> [Int] -> [(Int, Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip (Int -> [Int]
forall a. a -> [a]
repeat Int
fidVar) [Int]
hypos) Int
fid)
instance Binary Production where
put :: Production -> Put
put (PApply Int
ruleid [PArg]
args) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Int, [PArg]) -> Put
forall t. Binary t => t -> Put
put (Int
ruleid,[PArg]
args)
put (PCoerce Int
fcat) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
fcat
get :: Get Production
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> (Int -> [PArg] -> Production)
-> Get Int -> Get [PArg] -> Get Production
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 Int -> [PArg] -> Production
PApply Get Int
forall t. Binary t => Get t
get Get [PArg]
forall t. Binary t => Get t
get
Word8
1 -> (Int -> Production) -> Get Int -> Get Production
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Int -> Production
PCoerce Get Int
forall t. Binary t => Get t
get
Word8
_ -> Get Production
forall a. Get a
decodingError
instance Binary Literal where
put :: Literal -> Put
put (LStr String
s) = Word8 -> Put
putWord8 Word8
0 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> Put
forall t. Binary t => t -> Put
put String
s
put (LInt Int
i) = Word8 -> Put
putWord8 Word8
1 Put -> Put -> Put
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> Put
forall t. Binary t => t -> Put
put Int
i
put (LFlt Double
d) = Word8 -> Put
putWord8 Word8
2 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
d
get :: Get Literal
get = do Word8
tag <- Get Word8
getWord8
case Word8
tag of
Word8
0 -> (String -> Literal) -> Get String -> Get Literal
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM String -> Literal
LStr Get String
forall t. Binary t => Get t
get
Word8
1 -> (Int -> Literal) -> Get Int -> Get Literal
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Int -> Literal
LInt Get Int
forall t. Binary t => Get t
get
Word8
2 -> (Double -> Literal) -> Get Double -> Get Literal
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Double -> Literal
LFlt Get Double
forall t. Binary t => Get t
get
Word8
_ -> Get Literal
forall a. Get a
decodingError
putArray :: (Binary e, IArray a e) => a Int e -> Put
putArray :: a Int e -> Put
putArray a Int e
a = do Int -> Put
forall t. Binary t => t -> Put
put ((Int, Int) -> Int
forall a. Ix a => (a, a) -> Int
rangeSize ((Int, Int) -> Int) -> (Int, Int) -> Int
forall a b. (a -> b) -> a -> b
$ a Int e -> (Int, Int)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
bounds a Int e
a)
(e -> Put) -> [e] -> Put
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ e -> Put
forall t. Binary t => t -> Put
put (a Int e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
elems a Int e
a)
getArray :: (Binary e, IArray a e) => Get (a Int e)
getArray :: Get (a Int e)
getArray = do Int
n <- Get Int
forall t. Binary t => Get t
get
[e]
xs <- Int -> Get e -> Get [e]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM Int
n Get e
forall t. Binary t => Get t
get
a Int e -> Get (a Int e)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Int, Int) -> [e] -> a Int e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
listArray (Int
0,Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [e]
xs)
putArray2 :: (Binary e, IArray a1 (a2 Int e), IArray a2 e) => a1 Int (a2 Int e) -> Put
putArray2 :: a1 Int (a2 Int e) -> Put
putArray2 a1 Int (a2 Int e)
a = do Int -> Put
forall t. Binary t => t -> Put
put ((Int, Int) -> Int
forall a. Ix a => (a, a) -> Int
rangeSize ((Int, Int) -> Int) -> (Int, Int) -> Int
forall a b. (a -> b) -> a -> b
$ a1 Int (a2 Int e) -> (Int, Int)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
bounds a1 Int (a2 Int e)
a)
(a2 Int e -> Put) -> [a2 Int e] -> Put
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ a2 Int e -> Put
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
a Int e -> Put
putArray (a1 Int (a2 Int e) -> [a2 Int e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
elems a1 Int (a2 Int e)
a)
getArray2 :: (Binary e, IArray a1 (a2 Int e), IArray a2 e) => Get (a1 Int (a2 Int e))
getArray2 :: Get (a1 Int (a2 Int e))
getArray2 = do Int
n <- Get Int
forall t. Binary t => Get t
get
[a2 Int e]
xs <- Int -> Get (a2 Int e) -> Get [a2 Int e]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM Int
n Get (a2 Int e)
forall e (a :: * -> * -> *).
(Binary e, IArray a e) =>
Get (a Int e)
getArray
a1 Int (a2 Int e) -> Get (a1 Int (a2 Int e))
forall (m :: * -> *) a. Monad m => a -> m a
return ((Int, Int) -> [a2 Int e] -> a1 Int (a2 Int e)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
listArray (Int
0,Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [a2 Int e]
xs)
decodingError :: Get a
decodingError = String -> Get a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"This file was compiled with different version of GF"