@@ -9,6 +9,7 @@ import Idris.Core.CaseTree
99import Idris.AbsSyntax
1010import Idris.Imports
1111import Idris.Error
12+import Idris.DeepSeq
1213import Idris.Delaborate
1314import qualified Idris.Docstrings as D
1415import Idris.Docstrings (Docstring)
@@ -25,6 +26,7 @@ import qualified Data.Text as T
2526import qualified Data.Set as S
2627
2728import Control.Monad
29+import Control.DeepSeq
2830import Control.Monad.State.Strict hiding (get, put)
2931import qualified Control.Monad.State.Strict as ST
3032import System.FilePath
@@ -37,44 +39,44 @@ ibcVersion = 90
3739
3840data IBCFile = IBCFile { ver :: Word8,
3941 sourcefile :: FilePath,
40− symbols :: [Name],
41− ibc_imports :: [(Bool, FilePath)],
42− ibc_importdirs :: [FilePath],
43− ibc_implicits :: [(Name, [PArg])],
44− ibc_fixes :: [FixDecl],
45− ibc_statics :: [(Name, [Bool])],
46− ibc_classes :: [(Name, ClassInfo)],
47− ibc_instances :: [(Bool, Name, Name)],
48− ibc_dsls :: [(Name, DSL)],
49− ibc_datatypes :: [(Name, TypeInfo)],
50− ibc_optimise :: [(Name, OptInfo)],
51− ibc_syntax :: [Syntax],
52− ibc_keywords :: [String],
53− ibc_objs :: [(Codegen, FilePath)],
54− ibc_libs :: [(Codegen, String)],
55− ibc_cgflags :: [(Codegen, String)],
56− ibc_dynamic_libs :: [String],
57− ibc_hdrs :: [(Codegen, String)],
58− ibc_access :: [(Name, Accessibility)],
59− ibc_total :: [(Name, Totality)],
60− ibc_totcheckfail :: [(FC, String)],
61− ibc_flags :: [(Name, [FnOpt])],
62− ibc_fninfo :: [(Name, FnInfo)],
63− ibc_cg :: [(Name, CGInfo)],
64− ibc_defs :: [(Name, Def)],
65− ibc_docstrings :: [(Name, (Docstring D.DocTerm, [(Name, Docstring D.DocTerm)]))],
66− ibc_transforms :: [(Name, (Term, Term))],
67− ibc_errRev :: [(Term, Term)],
68− ibc_coercions :: [Name],
69− ibc_lineapps :: [(FilePath, Int, PTerm)],
70− ibc_namehints :: [(Name, Name)],
71− ibc_metainformation :: [(Name, MetaInformation)],
72− ibc_errorhandlers :: [Name],
73− ibc_function_errorhandlers :: [(Name, Name, Name)], -- fn, arg, handler
74− ibc_metavars :: [(Name, (Maybe Name, Int, Bool))],
75− ibc_patdefs :: [(Name, ([([Name], Term, Term)], [PTerm]))],
76− ibc_postulates :: [Name],
77− ibc_parsedSpan :: Maybe FC
42+ symbols :: ![Name],
43+ ibc_imports :: ![(Bool, FilePath)],
44+ ibc_importdirs :: ![FilePath],
45+ ibc_implicits :: ![(Name, [PArg])],
46+ ibc_fixes :: ![FixDecl],
47+ ibc_statics :: ![(Name, [Bool])],
48+ ibc_classes :: ![(Name, ClassInfo)],
49+ ibc_instances :: ![(Bool, Name, Name)],
50+ ibc_dsls :: ![(Name, DSL)],
51+ ibc_datatypes :: ![(Name, TypeInfo)],
52+ ibc_optimise :: ![(Name, OptInfo)],
53+ ibc_syntax :: ![Syntax],
54+ ibc_keywords :: ![String],
55+ ibc_objs :: ![(Codegen, FilePath)],
56+ ibc_libs :: ![(Codegen, String)],
57+ ibc_cgflags :: ![(Codegen, String)],
58+ ibc_dynamic_libs :: ![String],
59+ ibc_hdrs :: ![(Codegen, String)],
60+ ibc_access :: ![(Name, Accessibility)],
61+ ibc_total :: ![(Name, Totality)],
62+ ibc_totcheckfail :: ![(FC, String)],
63+ ibc_flags :: ![(Name, [FnOpt])],
64+ ibc_fninfo :: ![(Name, FnInfo)],
65+ ibc_cg :: ![(Name, CGInfo)],
66+ ibc_defs :: ![(Name, Def)],
67+ ibc_docstrings :: ![(Name, (Docstring D.DocTerm, [(Name, Docstring D.DocTerm)]))],
68+ ibc_transforms :: ![(Name, (Term, Term))],
69+ ibc_errRev :: ![(Term, Term)],
70+ ibc_coercions :: ![Name],
71+ ibc_lineapps :: ![(FilePath, Int, PTerm)],
72+ ibc_namehints :: ![(Name, Name)],
73+ ibc_metainformation :: ![(Name, MetaInformation)],
74+ ibc_errorhandlers :: ![Name],
75+ ibc_function_errorhandlers :: ![(Name, Name, Name)], -- fn, arg, handler
76+ ibc_metavars :: ![(Name, (Maybe Name, Int, Bool))],
77+ ibc_patdefs :: ![(Name, ([([Name], Term, Term)], [PTerm]))],
78+ ibc_postulates :: ![Name],
79+ ibc_parsedSpan :: !(Maybe FC)
7880 }
7981 deriving Show
8082{-!
@@ -189,11 +191,11 @@ ibc i (IBCDyLib n) f = return f {ibc_dynamic_libs = n : ibc_dynamic_libs f }
189191ibc i (IBCHeader tgt n) f = return f { ibc_hdrs = (tgt, n) : ibc_hdrs f }
190192ibc i (IBCDef n) f
191193 = do f' <- case lookupDefExact n (tt_ctxt i) of
192− Just v -> do (v', (f', _)) <- runStateT (updateDef v) (f, length (symbols f))
193− return f' { ibc_defs = (n,v) : ibc_defs f' }
194+ Just v -> do -- (v', (f', _)) <- runStateT (updateDef v) (f, length (symbols f))
195+ return f { ibc_defs = (n,v) : ibc_defs f }
194196 _ -> ifail "IBC write failed"
195197 case lookupCtxtExact n (idris_patdefs i) of
196− Just v -> return f' { ibc_patdefs = (n,v) : ibc_patdefs f' }
198+ Just v -> return f' { ibc_patdefs = (n,v) : ibc_patdefs f }
197199 _ -> return f' -- Not a pattern definition
198200 where
199201 updateDef :: Def -> StateT (IBCFile, Int) Idris Def
@@ -296,43 +298,43 @@ process reexp i fn
296298 v <- verbose
297299 quiet <- getQuiet
298300-- when (v && srcok && not quiet) $ iputStrLn $ "Skipping " ++ sourcefile i
299− pImportDirs (ibc_importdirs i)
300− pImports (ibc_imports i)
301− pImps (ibc_implicits i)
302− pFixes (ibc_fixes i)
303− pStatics (ibc_statics i)
304− pClasses (ibc_classes i)
305− pInstances (ibc_instances i)
306− pDSLs (ibc_dsls i)
307− pDatatypes (ibc_datatypes i)
308− pOptimise (ibc_optimise i)
309− pSyntax (ibc_syntax i)
310− pKeywords (ibc_keywords i)
311− pObjs (ibc_objs i)
312− pLibs (ibc_libs i)
313− pCGFlags (ibc_cgflags i)
314− pDyLibs (ibc_dynamic_libs i)
315− pHdrs (ibc_hdrs i)
316− pDefs reexp (symbols i) (ibc_defs i)
317− pPatdefs (ibc_patdefs i)
318− pAccess reexp (ibc_access i)
319− pFlags (ibc_flags i)
320− pFnInfo (ibc_fninfo i)
321− pTotal (ibc_total i)
322− pTotCheckErr (ibc_totcheckfail i)
323− pCG (ibc_cg i)
324− pDocs (ibc_docstrings i)
325− pCoercions (ibc_coercions i)
326− pTrans (ibc_transforms i)
327− pErrRev (ibc_errRev i)
328− pLineApps (ibc_lineapps i)
329− pNameHints (ibc_namehints i)
330− pMetaInformation (ibc_metainformation i)
331− pErrorHandlers (ibc_errorhandlers i)
332− pFunctionErrorHandlers (ibc_function_errorhandlers i)
333− pMetavars (ibc_metavars i)
334− pPostulates (ibc_postulates i)
335− pParsedSpan (ibc_parsedSpan i)
301+ pImportDirs $ force (ibc_importdirs i)
302+ pImports $ force (ibc_imports i)
303+ pImps $ force (ibc_implicits i)
304+ pFixes $ force (ibc_fixes i)
305+ pStatics $ force (ibc_statics i)
306+ pClasses $ force (ibc_classes i)
307+ pInstances $ force (ibc_instances i)
308+ pDSLs $ force (ibc_dsls i)
309+ pDatatypes $ force (ibc_datatypes i)
310+ pOptimise $ force (ibc_optimise i)
311+ pSyntax $ force (ibc_syntax i)
312+ pKeywords $ force (ibc_keywords i)
313+ pObjs $ force (ibc_objs i)
314+ pLibs $ force (ibc_libs i)
315+ pCGFlags $ force (ibc_cgflags i)
316+ pDyLibs $ force (ibc_dynamic_libs i)
317+ pHdrs $ force (ibc_hdrs i)
318+ pDefs reexp (symbols i) $ force (ibc_defs i)
319+ pPatdefs $ force (ibc_patdefs i)
320+ pAccess reexp $ force (ibc_access i)
321+ pFlags $ force (ibc_flags i)
322+ pFnInfo $ force (ibc_fninfo i)
323+ pTotal $ force (ibc_total i)
324+ pTotCheckErr $ force (ibc_totcheckfail i)
325+ pCG $ force (ibc_cg i)
326+ pDocs $ force (ibc_docstrings i)
327+ pCoercions $ force (ibc_coercions i)
328+ pTrans $ force (ibc_transforms i)
329+ pErrRev $ force (ibc_errRev i)
330+ pLineApps $ force (ibc_lineapps i)
331+ pNameHints $ force (ibc_namehints i)
332+ pMetaInformation $ force (ibc_metainformation i)
333+ pErrorHandlers $ force (ibc_errorhandlers i)
334+ pFunctionErrorHandlers $ force (ibc_function_errorhandlers i)
335+ pMetavars $ force (ibc_metavars i)
336+ pPostulates $ force (ibc_postulates i)
337+ pParsedSpan $ force (ibc_parsedSpan i)
336338
337339timestampOlder :: FilePath -> FilePath -> Idris ()
338340timestampOlder src ibc = do srct <- runIO $ getModificationTime src
@@ -462,13 +464,13 @@ pPatdefs :: [(Name, ([([Name], Term, Term)], [PTerm]))] -> Idris ()
462464pPatdefs ds
463465 = mapM_ (\ (n, d) ->
464466 do i <- getIState
465− putIState (i { idris_patdefs = addDef n d (idris_patdefs i) }))
467+ putIState (i { idris_patdefs = addDef n (force d) (idris_patdefs i) }))
466468 ds
467469
468470pDefs :: Bool -> [Name] -> [(Name, Def)] -> Idris ()
469471pDefs reexp syms ds
470472 = mapM_ (\ (n, d) ->
471− do let d' = updateDef d
473+ do let d' = force d -- (updateDef d)
472474 case d' of
473475 TyDecl _ _ -> return ()
474476 _ -> do iLOG $ "SOLVING " ++ show n