packages feed

numhask-prelude 0.1.0.1 → 0.3.1

raw patch · 5 files changed

+140/−120 lines, 5 filesdep +numhask-spacedep ~basedep ~doctestdep ~numhask

Dependencies added: numhask-space

Dependency ranges changed: base, doctest, numhask, numhask-prelude

Files

numhask-prelude.cabal view
@@ -1,54 +1,73 @@-name:           numhask-prelude-version:        0.1.0.1-synopsis:       A numeric prelude-description:    A numeric prelude, combining protolude and numhask.-category:       mathematics-homepage:       https://github.com/tonyday567/numhask#readme-bug-reports:    https://github.com/tonyday567/numhask/issues-author:         Tony Day-maintainer:     tonyday567@gmail.com-copyright:      Tony Day-license:        BSD3-license-file:   LICENSE-build-type:     Simple-cabal-version:  >= 1.18--extra-source-files:-    stack.yaml-+name: numhask-prelude+version: 0.3.1+synopsis:+  A numeric prelude+description:+  A numeric prelude, combining protolude and numhask.+category:+  mathematics+homepage:+  https://github.com/tonyday567/numhask#readme+bug-reports:+  https://github.com/tonyday567/numhask/issues+author:+  Tony Day+maintainer:+  tonyday567@gmail.com+copyright:+  Tony Day+license:+  BSD3+license-file:+  LICENSE+build-type:+  Simple+cabal-version:+  1.18 source-repository head-  type: git-  location: https://github.com/tonyday567/numhask-+  type:+    git+  location:+    https://github.com/tonyday567/numhask+  subdir:+    numhask-prelude library   hs-source-dirs:-      src-  default-extensions: NegativeLiterals NoImplicitPrelude OverloadedStrings UnicodeSyntax+    src+  default-extensions:+    NegativeLiterals+    NoImplicitPrelude+    OverloadedStrings+    UnicodeSyntax   ghc-options:-      -Wall-      -Wcompat-      -Wincomplete-record-updates-      -Wincomplete-uni-patterns-      -Wredundant-constraints+    -Wall+    -Wcompat+    -Wincomplete-record-updates+    -Wincomplete-uni-patterns+    -Wredundant-constraints   build-depends:-      base >=4.7 && <4.12-    , numhask >=0.2.3.0 && <0.3+      base >=4.7 && <5+    , numhask >=0.3 && <0.4+    , numhask-space >=0.1.1 && <0.2     , protolude >=0.1 && <0.3   exposed-modules:-      NumHask.Prelude-      NumHask.Error-      NumHask.Examples-  other-modules:-      Paths_numhask_prelude+    NumHask.Prelude+    NumHask.Error+    NumHask.Examples   default-language: Haskell2010- test-suite test-  type: exitcode-stdio-1.0-  main-is: test.hs+  type:+    exitcode-stdio-1.0+  main-is:+    test.hs   hs-source-dirs:-      test-  default-extensions: NegativeLiterals NoImplicitPrelude OverloadedStrings UnicodeSyntax+    test+  default-extensions:+    NegativeLiterals+    NoImplicitPrelude+    OverloadedStrings+    UnicodeSyntax   build-depends:-      doctest-    , numhask-prelude+      doctest >=0.13 && <0.17+    , numhask-prelude >=0.3 && <0.4   default-language: Haskell2010
src/NumHask/Examples.hs view
@@ -1,10 +1,11 @@ {-# LANGUAGE DataKinds #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE RebindableSyntax #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE RebindableSyntax #-} {-# OPTIONS_GHC -Wall #-}-{-# OPTIONS_GHC -fno-warn-unused-imports #-}  -- | NumHask usage examples module NumHask.Examples@@ -24,15 +25,15 @@      -- ** Matrices     -- $matrices-  ) where--import NumHask.Prelude+  )+where  -- $imports -- NumHask.Prelude is a replacement for the standard prelude with the 'NoImplicitPrelude' extension explicitly required. -- -- $setup -- >>> :set -XNoImplicitPrelude+-- >>> :set -XFlexibleContexts -- >>> import NumHask.Prelude -- -- $basic@@ -44,17 +45,17 @@ -- 0 -- >>> 1 * 1 -- 1--- >>> 1 / 1+-- >>> 1.0 / 1.0 -- 1.0 -- -- Note that the literal numbers in the divide above defaulted to Float rather than Int. -- -- >>> 1 / (1::Int) -- ...--- ... No instance for (MultiplicativeGroup Int)+-- ... No instance for (Divisive Int) ... -- ... ----- >>> 1 / fromIntegral (1::Int)+-- >>> 1.0 / fromIntegral (1::Int) -- 1.0 -- -- RebindableSyntax removes the Haskell98 link between literal numbers and base classes.  Literal numbers are pre-processed by ghc as `fromInteger 1` and `fromRational 1.0`.@@ -96,10 +97,19 @@ -- -- 'BoundedField' --+-- >>> 1.0/0.0+-- Infinity+-- >>> -1.0/0.0+-- -Infinity+-- >>> 0.0/0.0 + 1.0+-- NaN+-- -- >>> one/zero -- Infinity+-- -- >>> -one/zero -- -Infinity+-- -- >>> zero/zero+one -- NaN --@@ -125,17 +135,5 @@ -- (-1) :+ (-2) -- >>> (1 :+ (-2)) * ((-2) :+ 4) -- 6 :+ 8--- >>> (1 :+ (-1)) / (2 :+ 2)+-- >>> (1.0 :+ (-1.0)) / (2.0 :+ 2.0) -- 0.0 :+ (-0.5)--newtype PositiveFloat = PositiveFloat { unPositive :: Float } deriving (Show, Eq, AdditiveMagma, AdditiveAssociative, AdditiveUnital, AdditiveCommutative, Additive, MultiplicativeMagma, MultiplicativeUnital, MultiplicativeAssociative, MultiplicativeCommutative, Multiplicative, MultiplicativeInvertible, MultiplicativeGroup, Distribution, Semiring, Ring, CRing, Semifield, UpperBoundedField)--instance AdditiveInvertible PositiveFloat where-  negate _ = nan--instance AdditiveGroup PositiveFloat--instance Bounded PositiveFloat where-  minBound = zero-  maxBound = infinity-
src/NumHask/Prelude.hs view
@@ -10,65 +10,72 @@   , (<>)   , Semigroup #endif-    -- RebindableSyntax takes fromString and fail away so we need to put it back in+    -- RebindableSyntax removes all sorts of stuff that we then have to put back in   , fromString   , fail-  , Complex(..)-  , module NumHask.Data.LogField-  , Natural(..)+  , ifThenElse+  , fromList+  , fromListN     -- * Algebraic Heirarchy     -- $instances-  , module NumHask.Algebra.Additive-  , module NumHask.Algebra.Basis-  , module NumHask.Algebra.Distribution-  , module NumHask.Algebra.Field-  , module NumHask.Algebra.Integral-  , module NumHask.Algebra.Magma-  , module NumHask.Algebra.Metric-  , module NumHask.Algebra.Module-  , module NumHask.Algebra.Multiplicative-  , module NumHask.Algebra.Rational-  , module NumHask.Algebra.Ring-  , module NumHask.Algebra.Singleton-+  , module NumHask.Algebra.Abstract.Action+  , module NumHask.Algebra.Abstract.Additive+  , module NumHask.Algebra.Abstract.Field+  , module NumHask.Algebra.Abstract.Group+  , module NumHask.Algebra.Abstract.Homomorphism+  , module NumHask.Algebra.Abstract.Lattice+  , module NumHask.Algebra.Abstract.Module+  , module NumHask.Algebra.Abstract.Multiplicative+  , module NumHask.Algebra.Abstract.Ring+  , module NumHask.Algebra.Abstract.TensorProduct+  , module NumHask.Algebra.Linear.Hadamard+  , module NumHask.Analysis.Banach+  , module NumHask.Analysis.Metric+  , module NumHask.Analysis.Space+  , module NumHask.Data.Complex   +  , module NumHask.Data.Integral+  , module NumHask.Data.Range+  , module NumHask.Data.LogField       +  , module NumHask.Data.Rational+  , module NumHask.Data.Pair+  , module NumHask.Data.Positive+  , Natural(..)+  , module NumHask.Exception   ) where-+  #if MIN_VERSION_base(4,11,0)-import Protolude-       hiding (Integral(..), Rep, Semiring(..), (*), (**),-               (+), (-), (/), (^), (^^), abs, acos, acosh, asin, asinh, atan,-               atan2, atanh, ceiling, cos, cosh, exp, floor, fromInteger,-               fromIntegral, even, odd, infinity, log, logBase, negate, pi, product,-               properFraction, recip, round, sin, sinh, sqrt, sum, tan, tanh, toInteger, trans,-               zero, fromRational, Ratio(..), Rational, reduce, gcd, subtract)+import Protolude hiding (Integral(..), Rep, Semiring(..), (*), (**), (+), (-), (/), (^), (^^), abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceiling, cos, cosh, exp, floor, fromInteger, fromIntegral, even, odd, infinity, log, logBase, negate, pi, product, properFraction, recip, round, sin, sinh, sqrt, sum, tan, tanh, toInteger, trans, truncate, zero, fromRational, Ratio(..), Rational, reduce, gcd, subtract, Complex(..), Sum(..), Product(..), isNaN, realPart, imagPart, polar, phase, mkPolar, magnitude, cis) #else-import Protolude-       hiding (Integral(..), Rep, Semiring(..), (*), (**),-               (+), (-), (/), (^), (^^), abs, acos, acosh, asin, asinh, atan,-               atan2, atanh, ceiling, cos, cosh, exp, floor, fromInteger,-               fromIntegral, even, odd, infinity, log, logBase, negate, pi, product,-               properFraction, recip, round, sin, sinh, sqrt, sum, tan, tanh, toInteger, trans,-               zero, fromRational, Ratio(..), Rational, reduce, gcd, subtract, (<>), Semigroup)+import Protolude hiding (Integral(..), Rep, Semiring(..), (*), (**), (+), (-), (/), (^), (^^), abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceiling, cos, cosh, exp, floor, fromInteger, fromIntegral, even, odd, infinity, log, logBase, negate, pi, product, properFraction, recip, round, sin, sinh, sqrt, sum, tan, tanh, toInteger, trans, truncate, zero, fromRational, Ratio(..), Rational, reduce, gcd, subtract, Complex(..), Sum(..), Product(..), isNaN, realPart, imagPart, polar, phase, mkPolar, magnitude, cis, (<>), Semigroup) import Data.Semigroup ((<>), Semigroup) #endif  import Control.Monad (fail) import Data.String-import GHC.Natural(Natural(..))--import NumHask.Algebra.Additive-import NumHask.Algebra.Basis-import NumHask.Algebra.Distribution-import NumHask.Algebra.Field-import NumHask.Algebra.Integral-import NumHask.Algebra.Magma-import NumHask.Algebra.Metric-import NumHask.Algebra.Module-import NumHask.Algebra.Multiplicative-import NumHask.Algebra.Rational-import NumHask.Algebra.Ring-import NumHask.Algebra.Singleton+import GHC.Natural (Natural(..))+import NumHask.Algebra.Abstract.Action+import NumHask.Algebra.Abstract.Additive+import NumHask.Algebra.Abstract.Field+import NumHask.Algebra.Abstract.Group+import NumHask.Algebra.Abstract.Homomorphism+import NumHask.Algebra.Abstract.Lattice+import NumHask.Algebra.Abstract.Module+import NumHask.Algebra.Abstract.Multiplicative+import NumHask.Algebra.Abstract.Ring+import NumHask.Algebra.Abstract.TensorProduct+import NumHask.Algebra.Linear.Hadamard+import NumHask.Analysis.Banach+import NumHask.Analysis.Metric+import NumHask.Analysis.Space+import NumHask.Data.Complex+import NumHask.Data.Integral+import NumHask.Data.Range import NumHask.Data.LogField+import NumHask.Data.Pair+import NumHask.Data.Positive+import NumHask.Data.Rational+import NumHask.Exception+import GHC.Exts  -- $backend -- NumHask imports Protolude as the prelude and replaces much of the 'Num' heirarchy in base.@@ -78,3 +85,9 @@ -- -- Instances for 'Int', 'Integer', 'Float', 'Double', 'Bool', 'Complex' and 'Natural'are supplied. --++-- | rebindable syntax splats this, and I'm not sure where it exists in GHC land+ifThenElse :: Bool -> a -> a -> a+ifThenElse True  x _ = x+ifThenElse False _ y = y+
− stack.yaml
@@ -1,8 +0,0 @@-resolver: nightly-2018-05-06--packages:-  - .-  # - ../numhask--extra-deps:-  - numhask-0.2.3.0
test/test.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE FlexibleInstances #-} {-# OPTIONS_GHC -Wall #-}  module Main where