GHCi statements to use HsExpansions route
Summary
Currently GHCi statements are typechecked using tcStmtsAndThen
in GHC.Tc.Gen.TcGhciStmts
.
tcStmtsAndThen
internally uses tcSyntaxOp
to typecheck statements.
We should instead be using GHC.Tc.Gen.Do.expandDoStmts
so that we can start removing the dependency from tcSyntaxOp
Steps to reproduce
ghci script
:set -XImpredicativeTypes
type Id = forall a. a -> a
t :: IO Id; t = return id
p :: Id -> (Bool, Int); p f = (f True, f 3)
x <- t
fails with the following error message:
Couldn't match type ‘a0’ with ‘Id’
Expected: IO a0
Actual: IO Id
Cannot instantiate unification variable ‘a0’
with a type involving polytypes: Id
In a stmt of an interactive GHCi command:
x <- GHC.GHCi.ghciStepIO :: IO a -> IO a t
Expected output is that it should assign polymorphic typed value id
to x
GHC
version: 9.9 (Head)