Skip to content

Commit 0a6bca5

Browse files
committed
Cleanup
1 parent 90ece8d commit 0a6bca5

File tree

1 file changed

+10
-14
lines changed
  • liquidhaskell-boot/src/Language/Haskell/Liquid/Bare

1 file changed

+10
-14
lines changed

liquidhaskell-boot/src/Language/Haskell/Liquid/Bare/Check.hs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Liquid.GHC.API as Ghc hiding ( Located
2525
, empty
2626
)
2727
import Control.Applicative ((<|>))
28+
import Control.Monad (guard)
2829
import Control.Monad.Reader
2930
import Data.Maybe
3031
import Data.Function (on)
@@ -71,12 +72,7 @@ checkTargetSrc cfg bare spec
7172

7273
isStratifiedTyCon :: BareSpec -> TyCon -> Bool
7374
isStratifiedTyCon bs tc = Ghc.tyConName tc `elem` sn
74-
where
75-
-- (Alecs): For some reason it can't see that they are the same
76-
-- GHC name, probably is due to some worker wrapper shenannigans
77-
sn = mapMaybe ctorName $ S.toList $ stratified bs
78-
ctorName (F.Loc _ _ (LHNResolved (LHRGHC c) _)) = Just c
79-
ctorName _ = Nothing
75+
where sn = mapMaybe (getLHGHCName . F.val) $ S.toList $ stratified bs
8076

8177
checkPositives :: BareSpec -> [TyCon] -> Diagnostics
8278
checkPositives bare tys = mkDiagnostics []
@@ -92,6 +88,8 @@ mkNonPosError tcs = [ ErrPosTyCon (getSrcSpan tc) (pprint tc) (pprint dc <+> ":"
9288
-- | Checking that stratified ctors are present --
9389
--------------------------------------------------
9490

91+
--- | Like 'Either' but the 'Semigroup' instance combines the failure
92+
--- | values.
9593
data Validation e a
9694
= Failure e
9795
| Success a
@@ -118,10 +116,9 @@ checkStratTys bare spec = valToEither
118116

119117
locateStratTcs :: BareSpec -> TyCon -> Maybe (SrcSpan, TyCon)
120118
locateStratTcs bs tc = listToMaybe $ mapMaybe ctorName $ S.toList $ stratified bs
121-
where
122-
ctorName (F.Loc s e (LHNResolved (LHRGHC c) _))
123-
| c == Ghc.tyConName tc = Just (GM.sourcePos2SrcSpan s e, tc)
124-
ctorName _ = Nothing
119+
where ctorName nm = do c <- getLHGHCName $ F.val nm
120+
guard $ c == Ghc.tyConName tc
121+
pure (GM.sourcePos2SrcSpan (loc nm) (locE nm), tc)
125122

126123
checkStratTy :: BareSpec -> SrcSpan -> TyCon -> Validation Diagnostics [Name]
127124
checkStratTy spec pos tycon =
@@ -136,10 +133,9 @@ checkStratCtor tcon spec pos datacon
136133
= Success [ nm ]
137134
| otherwise = Failure $ mkDiagnostics mempty [ err ]
138135
where err = ErrStratNotRefCtor pos (pprint $ dataConName datacon) (pprint $ Ghc.tyConName tcon)
139-
isThisDataCon (LHNResolved (LHRGHC c) _)
140-
| c == dataConName datacon = Just c
141-
isThisDataCon _ = Nothing
142-
136+
isThisDataCon c = do c' <- getLHGHCName c
137+
guard $ c' == dataConName datacon
138+
pure $ dataConName datacon
143139

144140
----------------------------------------------------------------------------------------------
145141
-- | Checking BareSpec ------------------------------------------------------------------------

0 commit comments

Comments
 (0)