prednote 0.18.0.4 → 0.20.0.0
raw patch · 8 files changed
+49/−30 lines, 8 filesdep +contravariant
Dependencies added: contravariant
Files
- current-versions.txt +7/−3
- lib/Data/Prednote/Expressions.hs +5/−0
- lib/Data/Prednote/Expressions/Infix.hs +6/−0
- lib/Data/Prednote/Expressions/RPN.hs +6/−0
- lib/Data/Prednote/Pdct.hs +9/−20
- lib/Data/Prednote/Test.hs +8/−0
- minimum-versions.txt +5/−3
- prednote.cabal +3/−4
current-versions.txt view
@@ -1,7 +1,7 @@ This package was tested to work with these dependency versions and compiler version. These are the default versions fetched by cabal install.-Tested as of: 2014-02-24 04:37:13.583324 UTC+Tested as of: 2014-03-01 19:44:29.719081 UTC Path to compiler: ghc-7.6.3 Compiler description: 7.6.3 @@ -32,12 +32,16 @@ time-1.4.0.1 unix-2.6.0.1 -/home/massysett/prednote/sunlight-27776/db:+/home/massysett/prednote/sunlight-17262/db: QuickCheck-2.6- prednote-0.18.0.4+ contravariant-0.4.4+ prednote-0.20.0.0 rainbow-0.6.0.4 random-1.0.1.1 split-0.2.2+ tagged-0.7 terminfo-0.4.0.0 text-1.1.0.0+ transformers-0.3.0.0+ transformers-compat-0.1.1.1
lib/Data/Prednote/Expressions.hs view
@@ -15,6 +15,7 @@ ) where import Data.Either (partitionEithers)+import Data.Functor.Contravariant import qualified Data.Text as X import qualified Data.Prednote.Expressions.Infix as I import qualified Data.Prednote.Expressions.RPN as R@@ -22,6 +23,10 @@ -- | A single type for both RPN tokens and infix tokens. newtype Token a = Token { unToken :: I.InfixToken a }++instance Contravariant Token where+ contramap f = Token . contramap f . unToken+ type Error = X.Text -- | Creates Operands from Pdct.
lib/Data/Prednote/Expressions/Infix.hs view
@@ -4,12 +4,18 @@ , createRPN ) where +import Data.Functor.Contravariant import qualified Data.Prednote.Expressions.RPN as R import qualified Data.Foldable as Fdbl data InfixToken a = TokRPN (R.RPNToken a) | TokParen Paren++instance Contravariant InfixToken where+ contramap f t = case t of+ TokRPN r -> TokRPN . contramap f $ r+ TokParen p -> TokParen p data Paren = Open | Close
lib/Data/Prednote/Expressions/RPN.hs view
@@ -6,6 +6,7 @@ -- where @and@ and @or@ are binary and @not@ is unary. module Data.Prednote.Expressions.RPN where +import Data.Functor.Contravariant import qualified Data.Foldable as Fdbl import qualified Data.Prednote.Pdct as P import Data.Prednote.Pdct ((&&&), (|||))@@ -19,6 +20,11 @@ data RPNToken a = TokOperand (P.Pdct a) | TokOperator Operator++instance Contravariant RPNToken where+ contramap f t = case t of+ TokOperand p -> TokOperand . contramap f $ p+ TokOperator o -> TokOperator o data Operator = OpAnd
lib/Data/Prednote/Pdct.hs view
@@ -23,8 +23,6 @@ , (|||) , always , never- , boxPdct- , boxNode -- * Controlling whether Pdct are shown in the results , hide@@ -77,6 +75,7 @@ -- # Imports +import Data.Functor.Contravariant import Data.Text (Text) import qualified Data.Text as X import Data.Monoid ((<>), mconcat, mempty)@@ -176,25 +175,15 @@ (|||) x y = Pdct "or" (const False) (Or [x, y]) infixr 2 ||| --- | Given a function that un-boxes values of type b, changes a Pdct--- from type a to type b.-boxPdct- :: (b -> a)- -> Pdct a- -> Pdct b-boxPdct f (Pdct l d n) = Pdct l d $ boxNode f n+instance Contravariant Pdct where+ contramap f (Pdct l d n) = Pdct l d $ contramap f n --- | Given a function that un-boxes values of type b, changes a Node--- from type a to type b.-boxNode- :: (b -> a)- -> Node a- -> Node b-boxNode f n = case n of- And ls -> And $ map (boxPdct f) ls- Or ls -> Or $ map (boxPdct f) ls- Not o -> Not $ boxPdct f o- Operand g -> Operand $ \b -> g (f b)+instance Contravariant Node where+ contramap f n = case n of+ And ls -> And $ map (contramap f) ls+ Or ls -> Or $ map (contramap f) ls+ Not o -> Not $ contramap f o+ Operand g -> Operand $ \b -> g (f b) -- # Result
lib/Data/Prednote/Test.hs view
@@ -24,6 +24,8 @@ ) where +import Control.Arrow (first)+import Data.Functor.Contravariant import Data.Maybe (fromMaybe) import Data.Monoid ((<>), mempty) import qualified Data.Text as X@@ -94,12 +96,18 @@ -- ^ Default verbosity for the test. } +instance Contravariant Test where+ contramap f t = t { testFunc = testFunc t . f }+ data TestResult a = TestResult { resultName :: Name , resultPass :: Pass , resultSubjects :: [(a, Pt.Result)] , resultDefaultVerbosity :: TestVerbosity }++instance Functor TestResult where+ fmap f t = t { resultSubjects = map (first f) . resultSubjects $ t } -- # Showing tests
minimum-versions.txt view
@@ -1,7 +1,7 @@ This package was tested to work with these dependency versions and compiler version. These are the minimum versions given in the .cabal file.-Tested as of: 2014-02-24 04:37:13.583324 UTC+Tested as of: 2014-03-01 19:44:29.719081 UTC Path to compiler: ghc-7.4.1 Compiler description: 7.4.1 @@ -33,12 +33,14 @@ time-1.4 unix-2.5.1.0 -/home/massysett/prednote/sunlight-27776/db:+/home/massysett/prednote/sunlight-17262/db: QuickCheck-2.6- prednote-0.18.0.4+ contravariant-0.2.0.1+ prednote-0.20.0.0 rainbow-0.6.0.4 random-1.0.1.1 split-0.2.2 terminfo-0.4.0.0 text-0.11.2.0+ transformers-0.3.0.0
prednote.cabal view
@@ -1,5 +1,5 @@ name: prednote-version: 0.18.0.4+version: 0.20.0.0 synopsis: Build and evaluate trees of predicates description: Build and evaluate trees of predicates. For example, you might build@@ -41,6 +41,7 @@ build-depends: base >= 4.5.0.0 && < 5+ , contravariant >= 0.2.0.1 , rainbow >=0.6.0.4 , split >=0.2.2 , text >= 0.11.2.0@@ -53,11 +54,9 @@ main-is: prednote-test.hs hs-source-dirs: . lib - -- Be sure the build-depends are listed within the if block;- -- otherwise, cabal install will always include these- -- build-dependencies in any build, even non-test builds. build-depends: base >=4.5.0.0 && < 5+ , contravariant >= 0.2.0.1 , QuickCheck >=2.6 , rainbow >=0.6.0.4 , text >= 0.11.2.0