packages feed

digestive-functors 0.7.1.0 → 0.7.1.1

raw patch · 5 files changed

+40/−41 lines, 5 filesdep ~QuickCheck

Dependency ranges changed: QuickCheck

Files

CHANGELOG view
@@ -1,3 +1,8 @@+- 0.7.1.1+    * Bump `QuickCheck` dependency to allow `QuickCheck-2.7`+    * Clean warnings in tests compilation+    * Don't use `Text.Read` to fix compilation on GHC 7.4+ - 0.7.1.0     * Add `validateOptional` function     * Add `condition` functions to allow composing multiple independent
digestive-functors.cabal view
@@ -1,5 +1,5 @@ Name:     digestive-functors-Version:  0.7.1.0+Version:  0.7.1.1 Synopsis: A practical formlet library  Description:@@ -88,7 +88,7 @@    Build-depends:     HUnit                      >= 1.2 && < 1.3,-    QuickCheck                 >= 2.5 && < 2.7,+    QuickCheck                 >= 2.5 && < 2.8,     test-framework             >= 0.4 && < 0.9,     test-framework-hunit       >= 0.3 && < 0.4,     test-framework-quickcheck2 >= 0.3 && < 0.4,
tests/Text/Digestive/Field/QTests.hs view
@@ -1,27 +1,27 @@-{-#LANGUAGE-   FlexibleInstances-  , TypeSynonymInstances-  , GeneralizedNewtypeDeriving-  #-}+-------------------------------------------------------------------------------- -- | Simple tests for applicative laws of the Result type+{-# LANGUAGE FlexibleInstances          #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TypeSynonymInstances       #-}+{-# OPTIONS_GHC -fno-warn-orphans #-} module Text.Digestive.Field.QTests        ( tests        ) where   ---------------------------------------------------------------------------------import Test.Framework (Test, testGroup)-import Test.QuickCheck hiding (Result, Success)-import Test.Framework.Providers.QuickCheck2 (testProperty)+import           Test.Framework                       (Test, testGroup)+import           Test.Framework.Providers.QuickCheck2 (testProperty)+import           Test.QuickCheck                      hiding (Result, Success)   ---------------------------------------------------------------------------------import Text.Digestive.Types+import           Text.Digestive.Types   ---------------------------------------------------------------------------------import Control.Applicative-import Control.Monad+import           Control.Applicative+import           Control.Monad   --------------------------------------------------------------------------------
tests/Text/Digestive/Form/QTests.hs view
@@ -1,28 +1,28 @@-{-# LANGUAGE-     GADTs-   , OverloadedStrings-   #-}+--------------------------------------------------------------------------------+{-# LANGUAGE GADTs             #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans #-} module Text.Digestive.Form.QTests        ( tests        ) where  ---------------------------------------------------------------------------------import Test.Framework-import Test.Framework.Providers.QuickCheck2-import Test.QuickCheck hiding (Success)+import           Test.Framework+import           Test.Framework.Providers.QuickCheck2+import           Test.QuickCheck                      hiding (Success)   ---------------------------------------------------------------------------------import Text.Digestive.Types-import Text.Digestive.Form.Internal-import Text.Digestive.Form.Internal.Field+import           Text.Digestive.Form.Internal+import           Text.Digestive.Form.Internal.Field+import           Text.Digestive.Types   ---------------------------------------------------------------------------------import Data.Text (Text,pack)-import Control.Monad-import Control.Monad.Identity-import Data.Maybe+import           Control.Monad+import           Control.Monad.Identity+import           Data.Maybe+import           Data.Text                            (Text, pack)  -------------------------------------------------------------------------------- 
tests/Text/Digestive/Tests/Fixtures.hs view
@@ -39,14 +39,12 @@ import           Control.Monad.Reader         (Reader, ask, runReader) import           Data.Text                    (Text) import qualified Data.Text                    as T-import qualified Text.Read                    as TR   -------------------------------------------------------------------------------- import           Text.Digestive.Form-import           Text.Digestive.Form.Internal import           Text.Digestive.Types-import           Text.Digestive.View+import           Text.Digestive.Util   --------------------------------------------------------------------------------@@ -128,12 +126,10 @@ -------------------------------------------------------------------------------- validateOptionalForm :: Monad m => Form Text m ValidateOptionalData validateOptionalForm = ValidateOptionalData-    <$> "first_field"  .: validateOptional (integer >=> even >=> greaterThan 0) (optionalString Nothing)+    <$> "first_field"  .: validateOptional (integer >=> even' >=> greaterThan 0) (optionalString Nothing)   where-    integer s = case (TR.readEither s) of-      Right n -> Success n-      Left  _ -> Error "not an integer"-    even n +    integer s = maybe (Error "not an integer") Success (readMaybe s)+    even' n       | n `mod` 2 == 0 = Success n       | otherwise      = Error "input must be even"     greaterThan x n@@ -150,15 +146,13 @@ -------------------------------------------------------------------------------- independentValidationsForm :: Monad m => Form [Text] m IndependentValidationsData independentValidationsForm = IndependentValidationsData-    <$> "first_field"  .: validate (notEmpty >=> integer >=> conditions [even, greaterThan 10]) (string Nothing)-  where +    <$> "first_field"  .: validate (notEmpty >=> integer >=> conditions [even', greaterThan 10]) (string Nothing)+  where     notEmpty x = if (null x)       then Error ["is empty"]       else Success x-    integer s = case (TR.readEither s) of-      Right n -> Success n-      Left  _ -> Error ["not an integer"]-    even n +    integer s = maybe (Error ["not an integer"]) Success (readMaybe s)+    even' n       | n `mod` 2 == 0 = Success n       | otherwise      = Error "input must be even"     greaterThan x n