packages feed

hedgehog-classes 0.2 → 0.2.0.1

raw patch · 3 files changed

+30/−17 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -3,6 +3,10 @@ `hedgehog-classes` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +0.2.0.1+=======+* improve reliability of hedgehog output filtering.+ 0.2 === 
hedgehog-classes.cabal view
@@ -2,7 +2,7 @@ name:   hedgehog-classes version:-  0.2+  0.2.0.1 synopsis:   Hedgehog will eat your typeclass bugs description:
src/Hedgehog/Classes/Common/Laws.hs view
@@ -23,8 +23,8 @@   ) where  import Control.Monad.IO.Class (MonadIO(liftIO))-import Data.Char (isSpace, isDigit)-import Data.Monoid (All(..), Any(..), Ap(..))+import Data.Char (isSpace)+import Data.Monoid (All(..), Ap(..)) import Hedgehog (Gen) import Hedgehog.Classes.Common.Property (Context(..)) import Hedgehog.Internal.Property (Property(..))@@ -289,25 +289,34 @@ -- ALERT!  stripLeading :: String -> String-stripLeading [] = []-stripLeading s@(x:xs) = if isSpace x-  then stripLeading xs-  else s+stripLeading = \case+  [] -> []+  s@(x:xs) -> if isSpace x+    then stripLeading xs+    else s -startsWithNumber :: String -> Bool-startsWithNumber [] = False-startsWithNumber (x:_) = isDigit x+-- | Like 'Data.Functor.Contravariant.Predicate', but its+--   Semigroup/Monoid instances are disjunctive instead of+--   conjunctive.+newtype DPredicate a = DPredicate { getDPredicate :: a -> Bool }+instance Semigroup (DPredicate a) where+  DPredicate p <> DPredicate q = DPredicate $ \a -> p a || q a+instance Monoid (DPredicate a) where+  mempty = DPredicate $ const False -startsWithCorner :: String -> Bool-startsWithCorner [] = False-startsWithCorner (x:_) = x == '┏'+startsWithCorner :: DPredicate String+startsWithCorner = DPredicate $ \case+  [] -> False+  (x:_) -> x == '┏' -containsSkinnyBar :: String -> Bool-containsSkinnyBar = any (== '│')+containsBar :: DPredicate String+containsBar = DPredicate $ \s -> any (== '┃') s  isBad :: String -> Bool-isBad x = getAny $ foldMap (\f -> Any (f x))-  [ startsWithNumber, startsWithCorner, containsSkinnyBar ]+isBad = getDPredicate $ mconcat+  [ startsWithCorner+  , containsBar+  ]  removeBadOutput :: String -> String removeBadOutput = unlines . go . lines where