@@ -13,6 +13,7 @@ module Wingman.CodeGen
13
13
import ConLike
14
14
import Control.Lens ((%~) , (<>~) , (&) )
15
15
import Control.Monad.Except
16
+ import Control.Monad.Reader (ask )
16
17
import Control.Monad.State
17
18
import Data.Bool (bool )
18
19
import Data.Functor ((<&>) )
@@ -24,6 +25,7 @@ import Data.Traversable
24
25
import DataCon
25
26
import Development.IDE.GHC.Compat
26
27
import GHC.Exts
28
+ import GHC.SourceGen (occNameToStr )
27
29
import GHC.SourceGen.Binds
28
30
import GHC.SourceGen.Expr
29
31
import GHC.SourceGen.Overloaded
@@ -39,7 +41,6 @@ import Wingman.Judgements.Theta
39
41
import Wingman.Machinery
40
42
import Wingman.Naming
41
43
import Wingman.Types
42
- import GHC.SourceGen (occNameToStr )
43
44
44
45
45
46
destructMatches
@@ -69,6 +70,7 @@ destructMatches use_field_puns f scrut t jdg = do
69
70
args = conLikeInstOrigArgTys' con apps
70
71
modify $ appEndo $ foldMap (Endo . evidenceToSubst) ev
71
72
subst <- gets ts_unifier
73
+ ctx <- ask
72
74
73
75
let names_in_scope = hyNamesInScope hy
74
76
names = mkManyGoodNames (hyNamesInScope hy) args
@@ -79,8 +81,8 @@ destructMatches use_field_puns f scrut t jdg = do
79
81
$ zip names'
80
82
$ coerce args
81
83
j = fmap (CType . substTyAddInScope subst . unCType)
82
- $ introduce hy'
83
- $ introduce method_hy
84
+ $ introduce ctx hy'
85
+ $ introduce ctx method_hy
84
86
$ withNewGoal g jdg
85
87
ext <- f con j
86
88
pure $ ext
@@ -289,13 +291,14 @@ letForEach rename solve (unHypothesis -> hy) jdg = do
289
291
case hy of
290
292
[] -> newSubgoal jdg
291
293
_ -> do
294
+ ctx <- ask
292
295
let g = jGoal jdg
293
296
terms <- fmap sequenceA $ for hy $ \ hi -> do
294
297
let name = rename $ hi_name hi
295
298
res <- tacticToRule jdg $ solve hi
296
299
pure $ fmap ((name,) . unLoc) res
297
300
let hy' = fmap (g <$ ) $ syn_val terms
298
301
matches = fmap (fmap (\ (occ, expr) -> valBind (occNameToStr occ) expr)) terms
299
- g <- fmap (fmap unLoc) $ newSubgoal $ introduce (userHypothesis hy') jdg
302
+ g <- fmap (fmap unLoc) $ newSubgoal $ introduce ctx (userHypothesis hy') jdg
300
303
pure $ fmap noLoc $ let' <$> matches <*> g
301
304
0 commit comments