testing-type-modifiers (empty) → 0.1.0.0
raw patch · 4 files changed
+125/−0 lines, 4 filesdep +basesetup-changed
Dependencies added: base
Files
- Data/Modifiers.hs +55/−0
- LICENSE +24/−0
- Setup.hs +2/−0
- testing-type-modifiers.cabal +44/−0
+ Data/Modifiers.hs view
@@ -0,0 +1,55 @@+{-# LANGUAGE DeriveDataTypeable #-}++-- | Type modifiers for writing properties that quantify over commonly used subsets of standard types. +-- | +-- | Currently there are only a few modifiers, more will be added. +module Data.Modifiers(+ -- ** List modifiers+ NonEmpty(..),+ mkNonEmpty,++ -- ** Numeric modifiers+ Nat(..),+ NonZero(..),+ + -- ** Character and string modifiers+ Unicode(..),+ unicodes,+ Printable(..),+ printables+ + ) where++import Data.Typeable++-- | A type of natural numbers such that @ nat a >= 0 @.+newtype Nat a = Nat {nat :: a} + deriving (Typeable, Show, Eq, Ord)++-- | A type of non-zero integers such that @ nonZero a /= 0 @.+newtype NonZero a = NonZero {nonZero :: a}+ deriving (Typeable, Show, Eq, Ord)+++-- | A type of non empty lists such that @ nonEmpty xs /= [] @.+newtype NonEmpty a = NonEmpty {nonEmpty :: [a]} + deriving (Typeable, Show)+mkNonEmpty :: a -> [a] -> NonEmpty a+mkNonEmpty x xs = NonEmpty $ x:xs++-- | Any unicode character. Should contain all values of the Char type.+newtype Unicode = Unicode {unicode :: Char} + deriving (Typeable, Show, Eq, Ord)++-- | Access function for unicode strings.+unicodes :: [Unicode] -> String+unicodes = map unicode++-- | Printable ASCII characters.+newtype Printable = Printable {printable :: Char}+ deriving (Typeable, Show)++-- | Access function for printable ASCII strings+printables :: [Printable] -> String+printables = map printable+
+ LICENSE view
@@ -0,0 +1,24 @@+This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/>
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple +main = defaultMain
+ testing-type-modifiers.cabal view
@@ -0,0 +1,44 @@+-- Initial testing-type-modifiers.cabal generated by cabal init. For +-- further documentation, see http://haskell.org/cabal/users-guide/ + +name: testing-type-modifiers +version: 0.1.0.0 +synopsis: Data type modifiers for property based testing +description: Property based testing libraries such as QuickCheck tend to include type modifiers. Most of them + are used to quantify over subsets of a type. For example a property on non-empty lists: + . + @ prop_tail_length (NonEmpty xs) = length (tail xs) == length xs - 1 @ + . + This library is intended to supply these modifiers to be used by testing libraries, in an effort to make + properties more portable between testing frameworks. + . + For every modifier it also provides an access function that converts to the underlying type, which + enables point-free style properties as such: + . + @ + prop_tail_length2 = (> 0) . length . nonEmpty + @ + + +license: PublicDomain +license-file: LICENSE +author: Jonas Duregård +maintainer: jonas.duregard@gmail.com +-- copyright: +category: Testing +build-type: Simple +-- extra-source-files: +cabal-version: >=1.10 + + +source-repository head + type: git + location: https://github.com/JonasDuregard/testing-type-modifiers + +library + exposed-modules: Data.Modifiers + -- other-modules: + other-extensions: DeriveDataTypeable + build-depends: base >=4 && <5 + -- hs-source-dirs: + default-language: Haskell2010