Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deepseq the result of typechecking a module to avoid a space leak. #891

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Cryptol/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module Cryptol.TypeCheck
, ppError
) where

import Control.DeepSeq

import Cryptol.ModuleSystem.Name
(liftSupply,mkDeclared,NameSource(..))
import qualified Cryptol.Parser.AST as P
Expand All @@ -48,7 +50,13 @@ import Cryptol.Utils.PP
import Cryptol.Utils.Panic(panic)

tcModule :: P.Module Name -> InferInput -> IO (InferOutput Module)
tcModule m inp = runInferM inp (inferModule m)
tcModule m inp =
do output <- runInferM inp (inferModule m)
-- Evaluate the result (including the module itself and also
-- warnings) to normal form to ensure that all uses of 'apSubst'
-- are fully evaluated and the (possibly very large) substitution
-- itself can be garbage collected.
pure $!! output

-- | Check a module instantiation, assuming that the functor has already
-- been checked.
Expand Down
2 changes: 1 addition & 1 deletion src/Cryptol/TypeCheck/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ data InferOutput a
-- ^ Type inference was successful.


deriving Show
deriving (Show, Generic, NFData)

bumpCounter :: InferM ()
bumpCounter = do RO { .. } <- IM ask
Expand Down