@@ -21,7 +21,7 @@ import System.Directory
21import Paths_idris
21import Paths_idris
23ibcVersion :: Word8
23ibcVersion :: Word8
24−ibcVersion = 15
24+ibcVersion = 16
26data IBCFile = IBCFile { ver :: Word8,
26data IBCFile = IBCFile { ver :: Word8,
27 sourcefile :: FilePath,
27 sourcefile :: FilePath,
@@ -30,6 +30,7 @@ data IBCFile = IBCFile { ver :: Word8,
30 ibc_fixes :: [FixDecl],
30 ibc_fixes :: [FixDecl],
31 ibc_statics :: [(Name, [Bool])],
31 ibc_statics :: [(Name, [Bool])],
32 ibc_classes :: [(Name, ClassInfo)],
32 ibc_classes :: [(Name, ClassInfo)],
33+ ibc_instances :: [(Name, Name)],
33 ibc_dsls :: [(Name, DSL)],
34 ibc_dsls :: [(Name, DSL)],
34 ibc_datatypes :: [(Name, TypeInfo)],
35 ibc_datatypes :: [(Name, TypeInfo)],
35 ibc_optimise :: [(Name, OptInfo)],
36 ibc_optimise :: [(Name, OptInfo)],
@@ -48,7 +49,7 @@ deriving instance Binary IBCFile
50initIBC :: IBCFile
51initIBC :: IBCFile
51−initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
52+initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
53loadIBC :: FilePath -> Idris ()
54loadIBC :: FilePath -> Idris ()
54loadIBC fp = do iLOG $ "Loading ibc " ++ fp
55loadIBC fp = do iLOG $ "Loading ibc " ++ fp
@@ -87,6 +88,8 @@ ibc i (IBCClass n) f
87 = case lookupCtxt Nothing n (idris_classes i) of
88 = case lookupCtxt Nothing n (idris_classes i) of
88 [v] -> return f { ibc_classes = (n,v): ibc_classes f }
89 [v] -> return f { ibc_classes = (n,v): ibc_classes f }
89 _ -> fail "IBC write failed"
90 _ -> fail "IBC write failed"
91+ibc i (IBCInstance n ins) f
92+ = return f { ibc_instances = (n,ins): ibc_instances f }
90ibc i (IBCDSL n) f
93ibc i (IBCDSL n) f
91 = case lookupCtxt Nothing n (idris_dsls i) of
94 = case lookupCtxt Nothing n (idris_dsls i) of
92 [v] -> return f { ibc_dsls = (n,v): ibc_dsls f }
95 [v] -> return f { ibc_dsls = (n,v): ibc_dsls f }
@@ -128,6 +131,7 @@ process i fn
128 pFixes (ibc_fixes i)
131 pFixes (ibc_fixes i)
129 pStatics (ibc_statics i)
132 pStatics (ibc_statics i)
130 pClasses (ibc_classes i)
133 pClasses (ibc_classes i)
134+ pInstances (ibc_instances i)
131 pDSLs (ibc_dsls i)
135 pDSLs (ibc_dsls i)
132 pDatatypes (ibc_datatypes i)
136 pDatatypes (ibc_datatypes i)
133 pOptimise (ibc_optimise i)
137 pOptimise (ibc_optimise i)
@@ -189,6 +193,9 @@ pClasses cs = mapM_ (\ (n, c) ->
189 = addDef n c (idris_classes i) }))
193 = addDef n c (idris_classes i) }))
196+pInstances :: [(Name, Name)] -> Idris ()
197+pInstances cs = mapM_ (\ (n, ins) -> addInstance n ins) cs
192pDSLs :: [(Name, DSL)] -> Idris ()
199pDSLs :: [(Name, DSL)] -> Idris ()
193pDSLs cs = mapM_ (\ (n, c) ->
200pDSLs cs = mapM_ (\ (n, c) ->
194 do i <- getIState
201 do i <- getIState
@@ -642,7 +649,7 @@ instance Binary Totality where
642 _ -> error "Corrupted binary data for Totality"
649 _ -> error "Corrupted binary data for Totality"
644instance Binary IBCFile where
651instance Binary IBCFile where
645− put (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20)
652+ put (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21)
646 = do put x1
653 = do put x1
@@ -663,6 +670,7 @@ instance Binary IBCFile where
667 = do x1 <- get
675 = do x1 <- get
668 if x1 == ibcVersion then
676 if x1 == ibcVersion then
@@ -685,7 +693,8 @@ instance Binary IBCFile where
685 x18 <- get
693 x18 <- get
686 x19 <- get
694 x19 <- get
687 x20 <- get
695 x20 <- get
688− return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20)
697+ return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21)
689 else return (initIBC { ver = x1 })
698 else return (initIBC { ver = x1 })
691instance Binary FnOpt where
700instance Binary FnOpt where
@@ -1068,7 +1077,7 @@ instance (Binary t) => Binary (PArg' t) where
1070instance Binary ClassInfo where
1079instance Binary ClassInfo where
1071− put (CI x1 x2 x3 x4)
1080+ put (CI x1 x2 x3 x4 _)
1072 = do put x1
1081 = do put x1
@@ -1078,7 +1087,7 @@ instance Binary ClassInfo where
1078 x2 <- get
1087 x2 <- get
1079 x3 <- get
1088 x3 <- get
1080 x4 <- get
1089 x4 <- get
1081− return (CI x1 x2 x3 x4)
1090+ return (CI x1 x2 x3 x4 [])
1083instance Binary OptInfo where
1092instance Binary OptInfo where
1084 put (Optimise x1 x2 x3)
1093 put (Optimise x1 x2 x3)