@@ -3,6 +3,9 @@
33{-| Binary instances for the core datatypes -}
44module Idris.Core.Binary where
55
6+import Control.Applicative ((<*>), (<$>))
7+import Control.Monad (liftM2)
8+
69import Data.Binary
710import Data.Vector.Binary
811import qualified Data.Text as T
@@ -43,6 +46,22 @@ instance Binary Provenance where
4346 return (TooManyArgs x1)
4447 _ -> error "Corrupted binary data for Provenance"
4548
49+instance Binary UConstraint where
50+ put (ULT x1 x2) = putWord8 0 >> put x1 >> put x2
51+ put (ULE x1 x2) = putWord8 1 >> put x1 >> put x2
52+ get = do i <- getWord8
53+ case i of
54+ 0 -> ULT <$> get <*> get
55+ 1 -> ULE <$> get <*> get
56+ _ -> error "Corrupted binary data for UConstraint"
57+
58+instance Binary ConstraintFC where
59+ put (ConstraintFC x1 x2) = putWord8 0 >> put x1 >> put x2
60+ get = do i <- getWord8
61+ case i of
62+ 0 -> liftM2 ConstraintFC get get
63+ _ -> error "Corrupted binary data for ConstraintFC"
64+
4665instance Binary a => Binary (Err' a) where
4766 put (Msg str) = do putWord8 0
4867 put str
@@ -97,7 +116,12 @@ instance Binary a => Binary (Err' a) where
97116 put ns
98117 put (IncompleteTerm t) = do putWord8 17
99118 put t
100− put UniverseError = putWord8 18
119+ put (UniverseError x1 x2 x3 x4 x5) = do putWord8 18
120+ put x1
121+ put x2
122+ put x3
123+ put x4
124+ put x5
101125 put (UniqueError u n) = do putWord8 19
102126 put u
103127 put n
@@ -181,7 +205,7 @@ instance Binary a => Binary (Err' a) where
181205 15 -> fmap (CantResolve False) get
182206 16 -> fmap CantResolveAlts get
183207 17 -> fmap IncompleteTerm get
184− 18 -> return UniverseError
208+ 18 -> UniverseError <$> get <*> get <*> get <*> get <*> get
185209 19 -> do x <- get ; y <- get
186210 return $ UniqueError x y
187211 20 -> do x <- get ; y <- get