18
18
-- | This module defines the representation of Subtyping and WF Constraints,
19
19
-- and the code for syntax-directed constraint generation.
20
20
21
- module Language.Haskell.Liquid.Constraint.Generate ( generateConstraints ) where
21
+ module Language.Haskell.Liquid.Constraint.Generate ( generateConstraints , generateConstraintsWithEnv , caseEnv , consE ) where
22
22
23
23
import Outputable (Outputable )
24
24
import Prelude hiding (error )
@@ -76,6 +76,7 @@ import Language.Haskell.Liquid.Transforms.CoreToLogic (weakenResult)
76
76
import Language.Haskell.Liquid.Bare.DataType (makeDataConChecker )
77
77
78
78
import Language.Haskell.Liquid.Types hiding (binds , Loc , loc , Def )
79
+ import Debug.Trace
79
80
80
81
--------------------------------------------------------------------------------
81
82
-- | Constraint Generation: Toplevel -------------------------------------------
@@ -84,12 +85,18 @@ generateConstraints :: TargetInfo -> CGInfo
84
85
--------------------------------------------------------------------------------
85
86
generateConstraints info = {-# SCC "ConsGen" #-} execState act $ initCGI cfg info
86
87
where
87
- act = consAct cfg info
88
+ act = do { γ <- initEnv info; consAct γ cfg info }
88
89
cfg = getConfig info
89
90
90
- consAct :: Config -> TargetInfo -> CG ()
91
- consAct cfg info = do
92
- γ <- initEnv info
91
+ generateConstraintsWithEnv :: TargetInfo -> CGInfo -> CGEnv -> CGInfo
92
+ --------------------------------------------------------------------------------
93
+ generateConstraintsWithEnv info cgi γ = {-# SCC "ConsGenEnv" #-} execState act cgi
94
+ where
95
+ act = consAct γ cfg info
96
+ cfg = getConfig info
97
+
98
+ consAct :: CGEnv -> Config -> TargetInfo -> CG ()
99
+ consAct γ cfg info = do
93
100
let sSpc = gsSig . giSpec $ info
94
101
let gSrc = giSrc info
95
102
when (gradual cfg) (mapM_ (addW . WfC γ . val . snd ) (gsTySigs sSpc ++ gsAsmSigs sSpc))
@@ -191,10 +198,11 @@ makeRecType :: (Enum a1, Eq a1, Num a1, F.Symbolic a)
191
198
makeRecType autoenv t vs dxs is
192
199
= mergecondition t $ fromRTypeRep $ trep {ty_binds = xs', ty_args = ts'}
193
200
where
194
- (xs', ts') = unzip $ replaceN (last is) (makeDecrType autoenv vdxs) xts
201
+ (xs', ts') = unzip $ replaceN (last is) (fromLeft $ makeDecrType autoenv vdxs) xts
195
202
vdxs = zip vs dxs
196
203
xts = zip (ty_binds trep) (ty_args trep)
197
204
trep = toRTypeRep $ unOCons t
205
+ fromLeft (Left x) = x
198
206
199
207
unOCons :: RType c tv r -> RType c tv r
200
208
unOCons (RAllT v t r) = RAllT v (unOCons t) r
@@ -425,6 +433,9 @@ consCB _ _ γ (NonRec x _) | isDictionary x
425
433
isDictionary = isJust . dlookup (denv γ)
426
434
427
435
436
+ consCB _ _ γ (NonRec x _ ) | isHoleVar x && typedHoles (getConfig γ)
437
+ = return γ
438
+
428
439
consCB _ _ γ (NonRec x def)
429
440
| Just (w, τ) <- grepDictionary def
430
441
, Just d <- dlookup (denv γ) w
@@ -673,9 +684,9 @@ cconsE' γ (Var x) t | isHoleVar x && typedHoles (getConfig γ)
673
684
= addHole x t γ
674
685
675
686
cconsE' γ e t
676
- = do te <- consE γ e
677
- te' <- instantiatePreds γ e te >>= addPost γ
678
- addC (SubC γ te' t) (" cconsE: " ++ " \n t = " ++ showpp t ++ " \n te = " ++ showpp te ++ GM. showPpr e)
687
+ = do te <- consE γ e
688
+ te' <- instantiatePreds γ e te >>= addPost γ
689
+ addC (SubC γ te' t) (" cconsE: " ++ " \n t = " ++ showpp t ++ " \n te = " ++ showpp te ++ GM. showPpr e)
679
690
680
691
lambdaSingleton :: CGEnv -> F. TCEmb TyCon -> Var -> CoreExpr -> UReft F. Reft
681
692
lambdaSingleton γ tce x e
0 commit comments