@@ -1,3 +1,5 @@
1+{-# OPTIONS_GHC -fwarn-incomplete-patterns -Werror #-}
1{-| Binary instances for the core datatypes -}
3{-| Binary instances for the core datatypes -}
2module Idris.Core.Binary where
4module Idris.Core.Binary where
@@ -7,6 +9,169 @@ import qualified Data.Text as T
8import Idris.Core.TT
10import Idris.Core.TT
12+instance Binary ErrorReportPart where
13+ put (TextPart msg) = do putWord8 0 ; put msg
14+ put (NamePart n) = do putWord8 1 ; put n
15+ put (TermPart t) = do putWord8 2 ; put t
16+ put (SubReport ps) = do putWord8 3 ; put ps
18+ get = do i <- getWord8
20+ 0 -> fmap TextPart get
21+ 1 -> fmap NamePart get
22+ 2 -> fmap TermPart get
23+ 3 -> fmap SubReport get
24+ _ -> error "Corrupted binary data for ErrorReportPart"
26+instance Binary a => Binary (Err' a) where
27+ put (Msg str) = do putWord8 0
29+ put (InternalMsg str) = do putWord8 1
31+ put (CantUnify x y z e ctxt i) = do putWord8 2
38+ put (InfiniteUnify n t ctxt) = do putWord8 3
42+ put (CantConvert x y ctxt) = do putWord8 4
46+ put (CantSolveGoal x ctxt) = do putWord8 5
49+ put (UnifyScope n1 n2 x ctxt) = do putWord8 6
54+ put (CantInferType str) = do putWord8 7
56+ put (NonFunctionType t1 t2) = do putWord8 8
59+ put (NotEquality t1 t2) = do putWord8 9
62+ put (TooManyArguments n) = do putWord8 10
64+ put (CantIntroduce t) = do putWord8 11
66+ put (NoSuchVariable n) = do putWord8 12
68+ put (NoTypeDecl n) = do putWord8 13
70+ put (NotInjective x y z) = do putWord8 14
74+ put (CantResolve t) = do putWord8 15
76+ put (CantResolveAlts ns) = do putWord8 16
78+ put (IncompleteTerm t) = do putWord8 17
80+ put UniverseError = putWord8 18
81+ put (UniqueError u n) = do putWord8 19
84+ put (UniqueKindError u n) = do putWord8 20
87+ put ProgramLineComment = putWord8 21
88+ put (Inaccessible n) = do putWord8 22
90+ put (NonCollapsiblePostulate n) = do putWord8 23
92+ put (AlreadyDefined n) = do putWord8 24
94+ put (ProofSearchFail e) = do putWord8 25
96+ put (NoRewriting t) = do putWord8 26
98+ put (At fc e) = do putWord8 27
101+ put (Elaborating str n e) = do putWord8 28
105+ put (ElaboratingArg n1 n2 ns e) = do putWord8 29
110+ put (ProviderError str) = do putWord8 30
112+ put (LoadingFailed str e) = do putWord8 31
115+ put (ReflectionError parts e) = do putWord8 32
118+ put (ReflectionFailed str e) = do putWord8 33
122+ get = do i <- getWord8
125+ 1 -> fmap InternalMsg get
126+ 2 -> do x <- get ; y <- get ; z <- get ; e <- get ; ctxt <- get ; i <- get
127+ return $ CantUnify x y z e ctxt i
128+ 3 -> do x <- get ; y <- get ; z <- get
129+ return $ InfiniteUnify x y z
130+ 4 -> do x <- get ; y <- get ; z <- get
131+ return $ CantConvert x y z
132+ 5 -> do x <- get ; y <- get
133+ return $ CantSolveGoal x y
134+ 6 -> do w <- get ; x <- get ; y <- get ; z <- get
135+ return $ UnifyScope w x y z
136+ 7 -> fmap CantInferType get
137+ 8 -> do x <- get ; y <- get
138+ return $ NonFunctionType x y
139+ 9 -> do x <- get ; y <- get
140+ return $ NotEquality x y
141+ 10 -> fmap TooManyArguments get
142+ 11 -> fmap CantIntroduce get
143+ 12 -> fmap NoSuchVariable get
144+ 13 -> fmap NoTypeDecl get
145+ 14 -> do x <- get ; y <- get ; z <- get
146+ return $ NotInjective x y z
147+ 15 -> fmap CantResolve get
148+ 16 -> fmap CantResolveAlts get
149+ 17 -> fmap IncompleteTerm get
150+ 18 -> return UniverseError
151+ 19 -> do x <- get ; y <- get
152+ return $ UniqueError x y
153+ 20 -> do x <- get ; y <- get
154+ return $ UniqueKindError x y
155+ 21 -> return ProgramLineComment
156+ 22 -> fmap Inaccessible get
157+ 23 -> fmap NonCollapsiblePostulate get
158+ 24 -> fmap AlreadyDefined get
159+ 25 -> fmap ProofSearchFail get
160+ 26 -> fmap NoRewriting get
161+ 27 -> do x <- get ; y <- get
163+ 28 -> do x <- get ; y <- get ; z <- get
164+ return $ Elaborating x y z
165+ 29 -> do w <- get ; x <- get ; y <- get ; z <- get
166+ return $ ElaboratingArg w x y z
167+ 30 -> fmap ProviderError get
168+ 31 -> do x <- get ; y <- get
169+ return $ LoadingFailed x y
170+ 32 -> do x <- get ; y <- get
171+ return $ ReflectionError x y
172+ 33 -> do x <- get ; y <- get
173+ return $ ReflectionFailed x y
174+ _ -> error "Corrupted binary data for Err'"
10----- Generated by 'derive'
175----- Generated by 'derive'
12instance Binary FC where
177instance Binary FC where
@@ -145,6 +310,7 @@ instance Binary Const where
145 B64V x1 -> putWord8 24 >> put x1
310 B64V x1 -> putWord8 24 >> put x1
146 BufferType -> putWord8 25
311 BufferType -> putWord8 25
147 ManagedPtrType -> putWord8 26
312 ManagedPtrType -> putWord8 26
313+ VoidType -> putWord8 27
149 = do i <- getWord8
315 = do i <- getWord8
150 case i of
316 case i of
@@ -187,7 +353,7 @@ instance Binary Const where
187 24 -> fmap B64V get
353 24 -> fmap B64V get
188 25 -> return BufferType
354 25 -> return BufferType
189 26 -> return ManagedPtrType
355 26 -> return ManagedPtrType
190−
356+ 27 -> return VoidType
191 _ -> error "Corrupted binary data for Const"
357 _ -> error "Corrupted binary data for Const"
@@ -208,6 +374,8 @@ instance Binary Raw where
209 RForce x1 -> do putWord8 5
375 RForce x1 -> do putWord8 5
377+ RUType x1 -> do putWord8 6
212 = do i <- getWord8
380 = do i <- getWord8
213 case i of
381 case i of
@@ -225,6 +393,8 @@ instance Binary Raw where
225 return (RConstant x1)
393 return (RConstant x1)
226 5 -> do x1 <- get
394 5 -> do x1 <- get
227 return (RForce x1)
395 return (RForce x1)
228 _ -> error "Corrupted binary data for Raw"
398 _ -> error "Corrupted binary data for Raw"