Skip to content

Commit 77b0bf9

Browse files
committed
Use lens to clean types
1 parent 13b675a commit 77b0bf9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/PropR/Check.hs

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE RecordWildCards #-}
33
{-# LANGUAGE TypeFamilies #-}
44
{-# LANGUAGE CPP #-}
5+
{-# LANGUAGE LambdaCase #-}
56

67
-- |
78
-- Module : PropR.Check
@@ -34,6 +35,9 @@ import PropR.Configuration (CompileConfig (..))
3435
import PropR.Types (EExpr, EProblem (..), EProg, EProgFix, EProp)
3536
import PropR.Util (progAtTy, propVars, propFunArgVars, rdrNamePrint, rdrNameToStr)
3637

38+
import Control.Lens (transformOf)
39+
import Data.Data.Lens (uniplate)
40+
3741
#if __GLASGOW_HASKELL__ >= 908
3842
import GHC.Plugins (DoPmc(..))
3943
#endif
@@ -43,10 +47,16 @@ alsoInferConstraints :: LHsType GhcPs -> LHsType GhcPs
4347
-- adds the "_ =>" for wildcards.
4448
-- Needed due to -XPartialTypeSignatures change, see A
4549
-- 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)
4851
where ctx :: LHsContext GhcPs
4952
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
5060
# else
5161
alsoInferConstraints = id
5262
#endif

0 commit comments

Comments
 (0)