packages feed

mixed-types-num 0.4.0.2 → 0.4.1

raw patch · 5 files changed

+54/−8 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Control.CollectErrors: class CanTestErrorsPresent es
+ Control.CollectErrors: hasError :: CanTestErrorsPresent es => es -> Bool
+ Control.CollectErrors: hasErrorCE :: CanTestErrorsPresent es => CollectErrors es v -> Bool
+ Numeric.CollectErrors: hasError :: CanTestErrorsPresent es => es -> Bool
+ Numeric.CollectErrors: hasErrorCN :: CN v -> Bool
+ Numeric.CollectErrors: instance Control.CollectErrors.CanTestErrorsPresent Numeric.CollectErrors.NumErrors
+ Numeric.MixedTypes.PreludeHiding: class Monad m => MonadFail (m :: Type -> Type)
- Numeric.MixedTypes.PreludeHiding: ($!) :: () => (a -> b) -> a -> b
+ Numeric.MixedTypes.PreludeHiding: ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- Numeric.MixedTypes.PreludeHiding: ($) :: () => (a -> b) -> a -> b
+ Numeric.MixedTypes.PreludeHiding: ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- Numeric.MixedTypes.PreludeHiding: (++) :: () => [a] -> [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: (++) :: [a] -> [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: (.) :: () => (b -> c) -> (a -> b) -> a -> c
+ Numeric.MixedTypes.PreludeHiding: (.) :: (b -> c) -> (a -> b) -> a -> c
- Numeric.MixedTypes.PreludeHiding: asTypeOf :: () => a -> a -> a
+ Numeric.MixedTypes.PreludeHiding: asTypeOf :: a -> a -> a
- Numeric.MixedTypes.PreludeHiding: break :: () => (a -> Bool) -> [a] -> ([a], [a])
+ Numeric.MixedTypes.PreludeHiding: break :: (a -> Bool) -> [a] -> ([a], [a])
- Numeric.MixedTypes.PreludeHiding: const :: () => a -> b -> a
+ Numeric.MixedTypes.PreludeHiding: const :: a -> b -> a
- Numeric.MixedTypes.PreludeHiding: curry :: () => ((a, b) -> c) -> a -> b -> c
+ Numeric.MixedTypes.PreludeHiding: curry :: ((a, b) -> c) -> a -> b -> c
- Numeric.MixedTypes.PreludeHiding: cycle :: () => [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: cycle :: [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: dropWhile :: () => (a -> Bool) -> [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: dropWhile :: (a -> Bool) -> [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: either :: () => (a -> c) -> (b -> c) -> Either a b -> c
+ Numeric.MixedTypes.PreludeHiding: either :: (a -> c) -> (b -> c) -> Either a b -> c
- Numeric.MixedTypes.PreludeHiding: error :: HasCallStack => [Char] -> a
+ Numeric.MixedTypes.PreludeHiding: error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
- Numeric.MixedTypes.PreludeHiding: errorWithoutStackTrace :: () => [Char] -> a
+ Numeric.MixedTypes.PreludeHiding: errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a
- Numeric.MixedTypes.PreludeHiding: fail :: Monad m => String -> m a
+ Numeric.MixedTypes.PreludeHiding: fail :: MonadFail m => String -> m a
- Numeric.MixedTypes.PreludeHiding: filter :: () => (a -> Bool) -> [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: filter :: (a -> Bool) -> [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: flip :: () => (a -> b -> c) -> b -> a -> c
+ Numeric.MixedTypes.PreludeHiding: flip :: (a -> b -> c) -> b -> a -> c
- Numeric.MixedTypes.PreludeHiding: fst :: () => (a, b) -> a
+ Numeric.MixedTypes.PreludeHiding: fst :: (a, b) -> a
- Numeric.MixedTypes.PreludeHiding: head :: () => [a] -> a
+ Numeric.MixedTypes.PreludeHiding: head :: [a] -> a
- Numeric.MixedTypes.PreludeHiding: id :: () => a -> a
+ Numeric.MixedTypes.PreludeHiding: id :: a -> a
- Numeric.MixedTypes.PreludeHiding: init :: () => [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: init :: [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: ioError :: () => IOError -> IO a
+ Numeric.MixedTypes.PreludeHiding: ioError :: IOError -> IO a
- Numeric.MixedTypes.PreludeHiding: iterate :: () => (a -> a) -> a -> [a]
+ Numeric.MixedTypes.PreludeHiding: iterate :: (a -> a) -> a -> [a]
- Numeric.MixedTypes.PreludeHiding: last :: () => [a] -> a
+ Numeric.MixedTypes.PreludeHiding: last :: [a] -> a
- Numeric.MixedTypes.PreludeHiding: map :: () => (a -> b) -> [a] -> [b]
+ Numeric.MixedTypes.PreludeHiding: map :: (a -> b) -> [a] -> [b]
- Numeric.MixedTypes.PreludeHiding: maybe :: () => b -> (a -> b) -> Maybe a -> b
+ Numeric.MixedTypes.PreludeHiding: maybe :: b -> (a -> b) -> Maybe a -> b
- Numeric.MixedTypes.PreludeHiding: readParen :: () => Bool -> ReadS a -> ReadS a
+ Numeric.MixedTypes.PreludeHiding: readParen :: Bool -> ReadS a -> ReadS a
- Numeric.MixedTypes.PreludeHiding: repeat :: () => a -> [a]
+ Numeric.MixedTypes.PreludeHiding: repeat :: a -> [a]
- Numeric.MixedTypes.PreludeHiding: reverse :: () => [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: reverse :: [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: scanl :: () => (b -> a -> b) -> b -> [a] -> [b]
+ Numeric.MixedTypes.PreludeHiding: scanl :: (b -> a -> b) -> b -> [a] -> [b]
- Numeric.MixedTypes.PreludeHiding: scanl1 :: () => (a -> a -> a) -> [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: scanl1 :: (a -> a -> a) -> [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: scanr :: () => (a -> b -> b) -> b -> [a] -> [b]
+ Numeric.MixedTypes.PreludeHiding: scanr :: (a -> b -> b) -> b -> [a] -> [b]
- Numeric.MixedTypes.PreludeHiding: scanr1 :: () => (a -> a -> a) -> [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: scanr1 :: (a -> a -> a) -> [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: seq :: () => a -> b -> b
+ Numeric.MixedTypes.PreludeHiding: seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b
- Numeric.MixedTypes.PreludeHiding: snd :: () => (a, b) -> b
+ Numeric.MixedTypes.PreludeHiding: snd :: (a, b) -> b
- Numeric.MixedTypes.PreludeHiding: span :: () => (a -> Bool) -> [a] -> ([a], [a])
+ Numeric.MixedTypes.PreludeHiding: span :: (a -> Bool) -> [a] -> ([a], [a])
- Numeric.MixedTypes.PreludeHiding: tail :: () => [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: tail :: [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: takeWhile :: () => (a -> Bool) -> [a] -> [a]
+ Numeric.MixedTypes.PreludeHiding: takeWhile :: (a -> Bool) -> [a] -> [a]
- Numeric.MixedTypes.PreludeHiding: uncurry :: () => (a -> b -> c) -> (a, b) -> c
+ Numeric.MixedTypes.PreludeHiding: uncurry :: (a -> b -> c) -> (a, b) -> c
- Numeric.MixedTypes.PreludeHiding: undefined :: HasCallStack => a
+ Numeric.MixedTypes.PreludeHiding: undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
- Numeric.MixedTypes.PreludeHiding: until :: () => (a -> Bool) -> (a -> a) -> a -> a
+ Numeric.MixedTypes.PreludeHiding: until :: (a -> Bool) -> (a -> a) -> a -> a
- Numeric.MixedTypes.PreludeHiding: unzip :: () => [(a, b)] -> ([a], [b])
+ Numeric.MixedTypes.PreludeHiding: unzip :: [(a, b)] -> ([a], [b])
- Numeric.MixedTypes.PreludeHiding: unzip3 :: () => [(a, b, c)] -> ([a], [b], [c])
+ Numeric.MixedTypes.PreludeHiding: unzip3 :: [(a, b, c)] -> ([a], [b], [c])
- Numeric.MixedTypes.PreludeHiding: zip :: () => [a] -> [b] -> [(a, b)]
+ Numeric.MixedTypes.PreludeHiding: zip :: [a] -> [b] -> [(a, b)]
- Numeric.MixedTypes.PreludeHiding: zip3 :: () => [a] -> [b] -> [c] -> [(a, b, c)]
+ Numeric.MixedTypes.PreludeHiding: zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
- Numeric.MixedTypes.PreludeHiding: zipWith :: () => (a -> b -> c) -> [a] -> [b] -> [c]
+ Numeric.MixedTypes.PreludeHiding: zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- Numeric.MixedTypes.PreludeHiding: zipWith3 :: () => (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
+ Numeric.MixedTypes.PreludeHiding: zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

Files

changelog.md view
@@ -1,6 +1,11 @@ # mixed-types-num change log -* v 0.4.1 2019-04-11+* v 0.4.1 2021-01-21+  * add hasErrorCE and hasErrorCN for testing if CE/CN values contain errors+* v 0.4.0.2 2020-08-02+  * remove smallcheck version upper bound+  * update to cabal-version >= 1.10+* v 0.4.0.1 2019-04-11   * fix infinite loop in some conversions * v 0.4.0 2019-04-10   * eliminated dependency on convertible, improving ghcjs compatibility
mixed-types-num.cabal view
@@ -1,11 +1,11 @@ name:           mixed-types-num-version:        0.4.0.2+version:        0.4.1 cabal-version:  >= 1.10 build-type:     Simple homepage:       https://github.com/michalkonecny/mixed-types-num author:         Michal Konecny maintainer:     Michal Konecny <mikkonecny@gmail.com>-copyright:      (c) 2015-2019 Michal Konecny+copyright:      (c) 2015-2021 Michal Konecny license:        BSD3 license-file:   LICENSE extra-source-files:  changelog.md
src/Control/CollectErrors.hs view
@@ -4,6 +4,7 @@ -- * Monad for collecting errors in expressions   CollectErrors(..), SuitableForCE , CanTestErrorsCertain(..), hasCertainErrorCE+, CanTestErrorsPresent(..), hasErrorCE , noValueCE, prependErrorsCE , filterValuesWithoutErrorCE, getValueIfNoErrorCE , ce2ConvertResult@@ -60,6 +61,12 @@  hasCertainErrorCE :: (CanTestErrorsCertain es) => (CollectErrors es v) -> Bool hasCertainErrorCE (CollectErrors _ es) = hasCertainError es++class CanTestErrorsPresent es where+  hasError :: es -> Bool++hasErrorCE :: (CanTestErrorsPresent es) => (CollectErrors es v) -> Bool+hasErrorCE (CollectErrors _ es) = hasError es  type SuitableForCE es = (Monoid es, Eq es, Show es, CanTestErrorsCertain es) 
src/MixedTypesNumPrelude.hs view
@@ -125,6 +125,25 @@ Note that when evaluating @1/0@, it evaluates to the error value printed above. This is not an exception, but a special value. +All arithmetic operations have been extended to CN types so that it is possible to+have expressions that operate exclusively on CN types:++>...> f (n :: CN Integer) = 1/(1/(n-1) + 1/n) :: CN Rational+>...> f (cn 0)+>{[(ERROR,division by 0)]}+>...> f (cn 1)+>{[(ERROR,division by 0)]}+>...> f (cn 2)+>2 % 3++The function hasErrorCN can be used to check whether any error occurred:++>...> hasErrorCN (1/0)+>True++>...> hasErrorCN (1/1)+>False+ When one is certain the division is well defined, one can remove @CN@ as follows:  >...> :t (1/!2)@@ -163,11 +182,19 @@  Also other harmless potential errors can be ignored using @(~!)@: ->...> (~!) $ sqrt (pi-pi)->[7.395570986446986e-32 ± <2^(-103)]+>...> (~!) $ sqrt (pi-pi) ? (bitsS 10)+> [0.000007629... ± 7.6294e-6 <2^(-17)] ->...> sqrt (pi-pi)->[7.395570986446986e-32 ± <2^(-103)]{[(POTENTIAL ERROR,out of range: sqrt: argument must be >= 0: [0 ± <2^(-240)])]}+>...> sqrt (pi-pi) ? (bitsS 10)+> [0.000007629... ± 7.6294e-6 <2^(-17)]{[(POTENTIAL ERROR,out of range: sqrt: argument must be >= 0: [0 ± 2.3283e-10 <2^(-32)])]}++When an error is present (which can be checked using hasErrorCN), the function hasCertainErrorCN can be used to further distinguish cases where the error is certain or potential:++>...> hasCertainErrorCN (sqrt (-1) ? (bitsS 10))+>True++>...> hasCertainErrorCN (sqrt (pi-pi) ? (bitsS 10))+>False   === Natural, integer and fractional powers
src/Numeric/CollectErrors.hs view
@@ -17,6 +17,7 @@   -- * Specialisation to numeric errors , CN , hasCertainError, hasCertainErrorCN+, hasError, hasErrorCN , noValueCN , noValueNumErrorCertainCN, noValueNumErrorPotentialCN , getMaybeValueCN, getErrorsCN, prependErrorsCN@@ -31,7 +32,7 @@ where  import Prelude-  (Show(..), Eq(..), Bool, String, Maybe(..), Either(..), (++), (.), or, map, fst, ($))+  (Show(..), Eq(..), Bool, String, Maybe(..), Either(..), (++), (.), or, map, fst, ($), null, not)  import Control.CollectErrors @@ -60,6 +61,12 @@  hasCertainErrorCN :: CN v -> Bool hasCertainErrorCN = hasCertainErrorCE++instance CanTestErrorsPresent NumErrors where+  hasError = not . null++hasErrorCN :: CN v -> Bool+hasErrorCN = hasErrorCE  sample_NumErrors :: Maybe [(ErrorCertaintyLevel, NumError)] sample_NumErrors = Nothing