@@ -22,7 +22,7 @@ import System.Directory
22import Paths_idris
22import Paths_idris
24ibcVersion :: Word8
24ibcVersion :: Word8
25−ibcVersion = 6
25+ibcVersion = 7
27data IBCFile = IBCFile { ver :: Word8,
27data IBCFile = IBCFile { ver :: Word8,
28 sourcefile :: FilePath,
28 sourcefile :: FilePath,
@@ -31,6 +31,7 @@ data IBCFile = IBCFile { ver :: Word8,
31 ibc_fixes :: [FixDecl],
31 ibc_fixes :: [FixDecl],
32 ibc_statics :: [(Name, [Bool])],
32 ibc_statics :: [(Name, [Bool])],
33 ibc_classes :: [(Name, ClassInfo)],
33 ibc_classes :: [(Name, ClassInfo)],
34+ ibc_datatypes :: [(Name, TypeInfo)],
34 ibc_optimise :: [(Name, OptInfo)],
35 ibc_optimise :: [(Name, OptInfo)],
35 ibc_syntax :: [Syntax],
36 ibc_syntax :: [Syntax],
36 ibc_keywords :: [String],
37 ibc_keywords :: [String],
@@ -44,7 +45,7 @@ deriving instance Binary IBCFile
46initIBC :: IBCFile
47initIBC :: IBCFile
47−initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] []
48+initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] []
49loadIBC :: FilePath -> Idris ()
50loadIBC :: FilePath -> Idris ()
50loadIBC fp = do iLOG $ "Loading ibc " ++ fp
51loadIBC fp = do iLOG $ "Loading ibc " ++ fp
@@ -83,6 +84,10 @@ ibc i (IBCClass n) f
83 = case lookupCtxt Nothing n (idris_classes i) of
84 = case lookupCtxt Nothing n (idris_classes i) of
84 [v] -> return f { ibc_classes = (n,v): ibc_classes f }
85 [v] -> return f { ibc_classes = (n,v): ibc_classes f }
85 _ -> fail "IBC write failed"
86 _ -> fail "IBC write failed"
88+ = case lookupCtxt Nothing n (idris_datatypes i) of
89+ [v] -> return f { ibc_datatypes = (n,v): ibc_datatypes f }
90+ _ -> fail "IBC write failed"
86ibc i (IBCOpt n) f = case lookupCtxt Nothing n (idris_optimisation i) of
91ibc i (IBCOpt n) f = case lookupCtxt Nothing n (idris_optimisation i) of
87 [v] -> return f { ibc_optimise = (n,v): ibc_optimise f }
92 [v] -> return f { ibc_optimise = (n,v): ibc_optimise f }
88 _ -> fail "IBC write failed"
93 _ -> fail "IBC write failed"
@@ -111,6 +116,7 @@ process i fn
111 pFixes (ibc_fixes i)
116 pFixes (ibc_fixes i)
112 pStatics (ibc_statics i)
117 pStatics (ibc_statics i)
113 pClasses (ibc_classes i)
118 pClasses (ibc_classes i)
119+ pDatatypes (ibc_datatypes i)
114 pOptimise (ibc_optimise i)
120 pOptimise (ibc_optimise i)
115 pSyntax (ibc_syntax i)
121 pSyntax (ibc_syntax i)
116 pKeywords (ibc_keywords i)
122 pKeywords (ibc_keywords i)
@@ -168,6 +174,13 @@ pClasses cs = mapM_ (\ (n, c) ->
168 = addDef n c (idris_classes i) }))
174 = addDef n c (idris_classes i) }))
177+pDatatypes :: [(Name, TypeInfo)] -> Idris ()
178+pDatatypes cs = mapM_ (\ (n, c) ->
180+ putIState (i { idris_datatypes
181+ = addDef n c (idris_datatypes i) }))
171pOptimise :: [(Name, OptInfo)] -> Idris ()
184pOptimise :: [(Name, OptInfo)] -> Idris ()
172pOptimise cs = mapM_ (\ (n, c) ->
185pOptimise cs = mapM_ (\ (n, c) ->
173 do i <- getIState
186 do i <- getIState
@@ -555,7 +568,7 @@ instance Binary Accessibility where
555 _ -> error "Corrupted binary data for Accessibility"
568 _ -> error "Corrupted binary data for Accessibility"
557instance Binary IBCFile where
570instance Binary IBCFile where
558− put (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)
571+ put (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16)
559 = do put x1
572 = do put x1
@@ -571,6 +584,7 @@ instance Binary IBCFile where
575 = do x1 <- get
589 = do x1 <- get
576 if x1 == ibcVersion then
590 if x1 == ibcVersion then
@@ -588,7 +602,8 @@ instance Binary IBCFile where
588 x13 <- get
602 x13 <- get
589 x14 <- get
603 x14 <- get
590 x15 <- get
604 x15 <- get
591− return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)
606+ return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16)
592 else return (initIBC { ver = x1 })
607 else return (initIBC { ver = x1 })
594instance Binary Fixity where
609instance Binary Fixity where
@@ -978,6 +993,11 @@ instance Binary OptInfo where
978 x3 <- get
993 x3 <- get
979 return (Optimise x1 x2 x3)
994 return (Optimise x1 x2 x3)
996+instance Binary TypeInfo where
997+ put (TI x1) = put x1
981instance Binary SynContext where
1001instance Binary SynContext where
983 = case x of
1003 = case x of