@@ -25,6 +25,7 @@ import Liquid.GHC.API as Ghc hiding ( Located
2525 , empty
2626 )
2727import Control.Applicative ((<|>) )
28+ import Control.Monad (guard )
2829import Control.Monad.Reader
2930import Data.Maybe
3031import Data.Function (on )
@@ -71,12 +72,7 @@ checkTargetSrc cfg bare spec
7172
7273isStratifiedTyCon :: BareSpec -> TyCon -> Bool
7374isStratifiedTyCon 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
8177checkPositives :: BareSpec -> [TyCon ] -> Diagnostics
8278checkPositives 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.
9593data Validation e a
9694 = Failure e
9795 | Success a
@@ -118,10 +116,9 @@ checkStratTys bare spec = valToEither
118116
119117locateStratTcs :: BareSpec -> TyCon -> Maybe (SrcSpan , TyCon )
120118locateStratTcs 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
126123checkStratTy :: BareSpec -> SrcSpan -> TyCon -> Validation Diagnostics [Name ]
127124checkStratTy 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