module Language.Haskell.Liquid.Transforms.Simplify (simplifyBounds) where
import Prelude hiding (error)
import Language.Haskell.Liquid.Types
import Language.Fixpoint.Types
import Language.Fixpoint.Types.Visitor
simplifyBounds :: SpecType -> SpecType
simplifyBounds = fmap go
where
go x = x { ur_reft = go' $ ur_reft x }
go' (Reft (v, p)) = Reft(v, dropBoundLike p)
dropBoundLike :: Expr -> Expr
dropBoundLike p
| isKvar p = p
| isBoundLikePred p = mempty
| otherwise = p
where
isKvar = not . null . kvars
isBoundLikePred :: Expr -> Bool
isBoundLikePred (PAnd ps) = simplifyLen <= length [p | p <- ps, isImp p ]
isBoundLikePred _ = False
isImp :: Expr -> Bool
isImp (PImp _ _) = True
isImp _ = False
simplifyLen :: Int
simplifyLen = 5