validity 0.11.0.1 → 0.12.0.0
raw patch · 7 files changed
+89/−81 lines, 7 filesdep ~basesetup-changed
Dependency ranges changed: base
Files
- CHANGELOG.md +72/−0
- LICENSE +1/−1
- Setup.hs +0/−3
- src/Data/RelativeValidity.hs +0/−23
- src/Data/Validity.hs +10/−45
- test/Data/ValiditySpec.hs +0/−5
- validity.cabal +6/−4
+ CHANGELOG.md view
@@ -0,0 +1,72 @@+# Changelog++## [0.12.0.0] - 2021-11-20++### Removed++* `RelativeValidity`, it was a misfeature.++## [0.11.0.0] - 2020-04-17++### Changed++* Made it so that Char is no longer trivially valid.++## [0.10.0.0] - 2020-04-12++### Changed++* Made it so that Word8, Word16, Word32 and Int8, Int16, Int32 are no longer trivially valid.++## [0.9.0.3] - 2020-02-10++### Changed++* Improved the 'validateRatioNormalised' to not crash on certain extreme values.++## [0.9.0.2] - 2019-09-27++### Added++* `isUtf16SurrogateCodePoint` and `validateCharNotUtf16SurrogateCodePoint`++### Changed++* The contents of the error message when using `validateNotNan` or `validateNotInfinite` is now more accurate.++### Added++* `validateRatioNotNan`+* `validateRatioNotInfinite`+* `validateRatioNormalised`++## [0.9.0.1] - 2018-12-05++### Changed++* The validity instance of `Ratio a` now disallows unnormalised values.+ So `0 %: 1` is valid, but `0 %: 2` is not.++## [0.9.0.0] - 2018-10-07++### Added++* `prettyValidate`, `validationIsValid`, `prettyValidation`+* `validateNotNaN`, `validateNotInfinite`++### Changed++* Renamed `prettyValidation` to `prettyValidate` before adding the new `prettyValidation`.+* `NaN`, `+Infinity` and `-Infinity` are now considered valid for both `Double` and `Float`.++## [0.8.0.0] - 2018-08-25++### Added+* `decorateList` in `Data.Validity`++### Changed+* `-0` is now a valid value for `Double` and `Float`.++## Older versions++No history before version 0.8.0.0
LICENSE view
@@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016-2020 Tom Sydney Kerckhove+Copyright (c) 2016-2021 Tom Sydney Kerckhove Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
− Setup.hs
@@ -1,3 +0,0 @@-import Distribution.Simple--main = defaultMain
− src/Data/RelativeValidity.hs
@@ -1,23 +0,0 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}---- | Relative validity-module Data.RelativeValidity- ( RelativeValidity (..),- isInvalidFor,- )-where---- | A class of types that have additional invariants defined upon them--- that aren't enforced by the type system------ If there is a @Validity a@ instance as well, then @a `isValidFor` b@--- should imply @isValid a@ for any @b@.------ If there is a @Validity b@ instance as well, then @a `isValidFor` b@--- should imply @isValid b@ for any @a@.-class RelativeValidity a b where- isValidFor :: a -> b -> Bool--isInvalidFor :: RelativeValidity a b => a -> b -> Bool-isInvalidFor a b = not $ isValidFor a b
src/Data/Validity.hs view
@@ -1,14 +1,10 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE TypeOperators #-}--#if MIN_VERSION_base(4,9,0) {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}-#endif -- | --@@ -91,41 +87,24 @@ -- * Re-exports Monoid (..),-#if MIN_VERSION_base(4,11,0)- Semigroup(..),-#endif+ Semigroup (..), ) where -#if MIN_VERSION_base(4,9,0)-import Data.List.NonEmpty (NonEmpty((:|)))-#endif--#if MIN_VERSION_base(4,8,0)-#else-import Data.Monoid-import Data.Ratio-#endif import Data.Bits ((.&.)) import Data.Char (ord) import Data.Either (isRight) import Data.Fixed (Fixed (MkFixed), HasResolution) import Data.Int (Int64) import Data.List (intercalate)+import Data.List.NonEmpty (NonEmpty ((:|))) import Data.Maybe (fromMaybe)-#if MIN_VERSION_base(4,8,0)-import GHC.Word (Word8(..), Word16(..), Word32(..), Word64(..))-#else-import Data.Word (Word)-import GHC.Word (Word8(..), Word16(..), Word32(..), Word64(..))-#endif import GHC.Exts (Char (..), isTrue#, leWord#, ord#, (<=#), (>=#)) import GHC.Generics import GHC.Int (Int16 (..), Int32 (..), Int8 (..))-#if MIN_VERSION_base(4,8,0) import GHC.Natural-#endif import GHC.Real (Ratio (..))+import GHC.Word (Word16 (..), Word32 (..), Word64 (..), Word8 (..)) -- | A class of types that have additional invariants defined upon them @@ -230,20 +209,12 @@ } deriving (Show, Eq, Generic) -#if MIN_VERSION_base(4,11,0) instance Semigroup Validation where- (Validation v1) <> (Validation v2) = Validation $ v1 ++ v2-#endif+ (Validation v1) <> (Validation v2) = Validation $ v1 ++ v2 -#if MIN_VERSION_base(4,11,0) instance Monoid Validation where mempty = Validation [] mappend = (<>)-#else-instance Monoid Validation where- mempty = Validation []- mappend (Validation v1) (Validation v2) = Validation $ v1 ++ v2-#endif -- | Declare any value to be valid in validation --@@ -397,17 +368,15 @@ instance Validity a => Validity [a] where validate = flip decorateList validate -#if MIN_VERSION_base(4,9,0) -- | A nonempty list is valid if all the elements are valid. -- -- See the instance for 'Validity [a]' for more information. instance Validity a => Validity (NonEmpty a) where- validate (e :| es) =- mconcat- [ annotate e "The first element of the nonempty list"- , annotate es "The rest of the elements of the nonempty list"- ]-#endif+ validate (e :| es) =+ mconcat+ [ annotate e "The first element of the nonempty list",+ annotate es "The rest of the elements of the nonempty list"+ ] -- | A Maybe thing is valid if the thing inside is valid or it's nothing -- It makes sense to assume that 'Nothing' is valid.@@ -564,13 +533,9 @@ instance Validity Integer where validate = trivialValidation -#if MIN_VERSION_base(4,8,0) -- | Valid according to 'isValidNatural'------ Only available with @base >= 4.8@. instance Validity Natural where- validate = declare "The Natural is valid." . isValidNatural-#endif+ validate = declare "The Natural is valid." . isValidNatural -- | Valid if the contained numbers are valid and the denominator is -- strictly positive.
test/Data/ValiditySpec.hs view
@@ -1,16 +1,11 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE MagicHash #-} --- {-# LANGUAGE CPP #-}- module Data.ValiditySpec ( spec, ) where --- #if !MIN_VERSION_base(4,7,0)--- import Data.Monoid--- #endif import Data.Maybe import Data.Validity import GHC.Exts (Char (..), chr#)
validity.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: validity-version: 0.11.0.1+version: 0.12.0.0 synopsis: Validity typeclass description: For more info, see <https://github.com/NorfairKing/validity the readme>. .@@ -39,6 +39,9 @@ license: MIT license-file: LICENSE build-type: Simple+extra-source-files:+ LICENSE+ CHANGELOG.md source-repository head type: git@@ -46,7 +49,6 @@ library exposed-modules:- Data.RelativeValidity Data.Validity other-modules: Paths_validity@@ -54,7 +56,7 @@ src ghc-options: -Wno-redundant-constraints build-depends:- base >=4.7 && <5+ base >=4.13 && <5 default-language: Haskell2010 test-suite validity-test@@ -67,7 +69,7 @@ test ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends:- base >=4.7 && <5+ base >=4.13 && <5 , hspec , validity default-language: Haskell2010