@@ -3,6 +3,9 @@
3{-| Binary instances for the core datatypes -}
3{-| Binary instances for the core datatypes -}
4module Idris.Core.Binary where
4module Idris.Core.Binary where
6+import Control.Applicative ((<*>), (<$>))
7+import Control.Monad (liftM2)
6import Data.Binary
9import Data.Binary
7import Data.Vector.Binary
10import Data.Vector.Binary
8import qualified Data.Text as T
11import qualified Data.Text as T
@@ -43,6 +46,22 @@ instance Binary Provenance where
43 return (TooManyArgs x1)
46 return (TooManyArgs x1)
44 _ -> error "Corrupted binary data for Provenance"
47 _ -> error "Corrupted binary data for Provenance"
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
54+ 0 -> ULT <$> get <*> get
55+ 1 -> ULE <$> get <*> get
56+ _ -> error "Corrupted binary data for UConstraint"
58+instance Binary ConstraintFC where
59+ put (ConstraintFC x1 x2) = putWord8 0 >> put x1 >> put x2
60+ get = do i <- getWord8
62+ 0 -> liftM2 ConstraintFC get get
63+ _ -> error "Corrupted binary data for ConstraintFC"
46instance Binary a => Binary (Err' a) where
65instance Binary a => Binary (Err' a) where
47 put (Msg str) = do putWord8 0
66 put (Msg str) = do putWord8 0
@@ -97,7 +116,12 @@ instance Binary a => Binary (Err' a) where
98 put (IncompleteTerm t) = do putWord8 17
117 put (IncompleteTerm t) = do putWord8 17
100− put UniverseError = putWord8 18
119+ put (UniverseError x1 x2 x3 x4 x5) = do putWord8 18
101 put (UniqueError u n) = do putWord8 19
125 put (UniqueError u n) = do putWord8 19
@@ -181,7 +205,7 @@ instance Binary a => Binary (Err' a) where
181 15 -> fmap (CantResolve False) get
205 15 -> fmap (CantResolve False) get
182 16 -> fmap CantResolveAlts get
206 16 -> fmap CantResolveAlts get
183 17 -> fmap IncompleteTerm get
207 17 -> fmap IncompleteTerm get
184− 18 -> return UniverseError
208+ 18 -> UniverseError <$> get <*> get <*> get <*> get <*> get
185 19 -> do x <- get ; y <- get
209 19 -> do x <- get ; y <- get
186 return $ UniqueError x y
210 return $ UniqueError x y
187 20 -> do x <- get ; y <- get
211 20 -> do x <- get ; y <- get