2
2
{-# LANGUAGE RecordWildCards #-}
3
3
{-# LANGUAGE TypeFamilies #-}
4
4
{-# LANGUAGE CPP #-}
5
+ {-# LANGUAGE LambdaCase #-}
5
6
6
7
-- |
7
8
-- Module : PropR.Check
@@ -34,6 +35,9 @@ import PropR.Configuration (CompileConfig (..))
34
35
import PropR.Types (EExpr , EProblem (.. ), EProg , EProgFix , EProp )
35
36
import PropR.Util (progAtTy , propVars , propFunArgVars , rdrNamePrint , rdrNameToStr )
36
37
38
+ import Control.Lens (transformOf )
39
+ import Data.Data.Lens (uniplate )
40
+
37
41
#if __GLASGOW_HASKELL__ >= 908
38
42
import GHC.Plugins (DoPmc (.. ))
39
43
#endif
@@ -43,10 +47,16 @@ alsoInferConstraints :: LHsType GhcPs -> LHsType GhcPs
43
47
-- adds the "_ =>" for wildcards.
44
48
-- Needed due to -XPartialTypeSignatures change, see A
45
49
-- https://gitlab.haskell.org/ghc/ghc/-/issues/24425
46
- alsoInferConstraints t@ (L _ (HsQualTy _ _ _)) = t
47
- alsoInferConstraints t = noLocA $ HsQualTy noExtField ctx t
50
+ alsoInferConstraints t = noLocA $ HsQualTy noExtField ctx (clean t)
48
51
where ctx :: LHsContext GhcPs
49
52
ctx = noLocA $ [noLocA $ HsWildCardTy noExtField]
53
+ clean :: LHsType GhcPs -> LHsType GhcPs
54
+ clean = transformOf uniplate $ \ case
55
+ L l (HsQualTy x (L cl ctxt) t) ->
56
+ L l (HsQualTy x (L cl $ filter (not . isWct) ctxt) t)
57
+ t -> t
58
+ isWct (L _ (HsWildCardTy _)) = True
59
+ isWct _ = False
50
60
# else
51
61
alsoInferConstraints = id
52
62
#endif
0 commit comments