numhask-prelude 0.4.0 → 0.5.0
raw patch · 2 files changed
+49/−53 lines, 2 filesdep ~numhaskdep ~numhask-prelude
Dependency ranges changed: numhask, numhask-prelude
Files
- numhask-prelude.cabal +3/−3
- src/NumHask/Prelude.hs +46/−50
numhask-prelude.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: numhask-prelude-version: 0.4.0+version: 0.5.0 synopsis: A numeric prelude description:@@ -46,7 +46,7 @@ -Wredundant-constraints build-depends: base >=4.7 && <5- , numhask >=0.3 && <0.5+ , numhask >=0.3 && <0.6 , protolude >=0.3 && <0.4 exposed-modules: NumHask.Prelude@@ -67,5 +67,5 @@ UnicodeSyntax build-depends: doctest >=0.13 && <0.17- , numhask-prelude >=0.4 && <0.5+ , numhask-prelude default-language: Haskell2010
src/NumHask/Prelude.hs view
@@ -1,53 +1,48 @@-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_HADDOCK prune #-} --- | A prelude for NumHask+-- | Combines 'Protolude' and 'numhask'. module NumHask.Prelude- ( -- * Backend- -- $backend- module Protolude-#if !MIN_VERSION_base(4,11,0)- , (<>)- , Semigroup-#endif- -- RebindableSyntax removes all sorts of stuff that we then have to put back in- , fromString- , fail- , ifThenElse- , fromList- , fromListN- -- * Algebraic Heirarchy+ ( -- * NumHask -- $instances- , module NumHask.Algebra.Abstract.Action- , module NumHask.Algebra.Abstract.Additive- , module NumHask.Algebra.Abstract.Field- , module NumHask.Algebra.Abstract.Group- , module NumHask.Algebra.Abstract.Lattice- , module NumHask.Algebra.Abstract.Module- , module NumHask.Algebra.Abstract.Multiplicative- , module NumHask.Algebra.Abstract.Ring- , module NumHask.Algebra.Linear.Hadamard- , module NumHask.Analysis.Metric- , module NumHask.Data.Complex- , module NumHask.Data.Integral- , 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, truncate, zero, fromRational, Ratio, reduce, gcd, subtract, Complex(..), Sum(..), Product(..), realPart, imagPart, polar, phase, mkPolar, magnitude, cis, toRational)-#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, truncate, zero, fromRational, Ratio(..), reduce, gcd, subtract, Complex(..), Sum(..), Product(..), realPart, imagPart, polar, phase, mkPolar, magnitude, cis, toRational, (<>), Semigroup)-import Data.Semigroup ((<>), Semigroup)-#endif + module NumHask.Algebra.Abstract.Action,+ module NumHask.Algebra.Abstract.Additive,+ module NumHask.Algebra.Abstract.Field,+ module NumHask.Algebra.Abstract.Group,+ module NumHask.Algebra.Abstract.Lattice,+ module NumHask.Algebra.Abstract.Module,+ module NumHask.Algebra.Abstract.Multiplicative,+ module NumHask.Algebra.Abstract.Ring,+ module NumHask.Algebra.Linear.Hadamard,+ module NumHask.Analysis.Metric,+ module NumHask.Data.Complex,+ module NumHask.Data.Integral,+ module NumHask.Data.LogField,+ module NumHask.Data.Rational,+ module NumHask.Data.Pair,+ module NumHask.Data.Positive,+ Natural (..),+ module NumHask.Exception,++ -- * Backend+ -- $backend++ id,+ module Protolude,+ -- | Using different types for numbers requires RebindableSyntax. This then removes all sorts of base-level stuff that has to be put back in.+ fromString,+ fail,+ ifThenElse,+ fromList,+ fromListN,+ )+where+ import Control.Monad (fail) import Data.String-import GHC.Natural (Natural(..))+import GHC.Exts+import GHC.Natural (Natural (..)) import NumHask.Algebra.Abstract.Action import NumHask.Algebra.Abstract.Additive import NumHask.Algebra.Abstract.Field@@ -65,19 +60,20 @@ import NumHask.Data.Positive import NumHask.Data.Rational import NumHask.Exception-import GHC.Exts+import Protolude hiding ((*), (**), (+), (-), (/), Complex (..), Integral (..), Product (..), Ratio, Rep, Semiring (..), Sum (..), (^), (^^), abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceiling, cis, cos, cosh, even, exp, floor, fromInteger, fromIntegral, fromRational, gcd, imagPart, infinity, log, logBase, magnitude, mkPolar, negate, odd, phase, pi, polar, product, properFraction, realPart, recip, reduce, round, sin, sinh, sqrt, subtract, sum, tan, tanh, toInteger, toRational, trans, truncate, zero)+import Control.Category (id) -- $backend--- NumHask imports Protolude as the prelude and replaces much of the 'Num' heirarchy in base.--- Usage of 'Semigroup' and 'Monoid' has been avoided to retain basic compatability.+-- NumHask imports Protolude as a starting prelude.+--+-- In addition, 'id' is imported (protolude uses 'identity')+ -- $instances--- Re-defines the numeric tower.+-- NumHask replaces much of the 'Num' and 'Real' heirarchies in protolude & base. -- -- 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 True x _ = x ifThenElse False _ y = y-