module Control.Super.Plugin.Debug
( containsAnyOf
, containsAllOf
, containsNoneOf
, pprToStr, sDocToStr
) where
import Data.List ( isInfixOf )
import Outputable
( Outputable(..), SDoc
, showSDocUnsafe )
pprToStr :: Outputable o => o -> String
pprToStr = sDocToStr . ppr
sDocToStr :: SDoc -> String
sDocToStr = showSDocUnsafe
containsAnyOf :: (Outputable o) => o -> [String] -> Bool
containsAnyOf obj = any (`isInfixOf` pprToStr obj)
containsAllOf :: (Outputable o) => o -> [String] -> Bool
containsAllOf obj = all (`isInfixOf` pprToStr obj)
containsNoneOf :: (Outputable o) => o -> [String] -> Bool
containsNoneOf obj = not . (obj `containsAnyOf`)