numhask-space 0.10.0.0 → 0.10.0.1
raw patch · 5 files changed
+39/−28 lines, 5 filesdep +QuickCheckdep ~basedep ~numhaskdep ~text
Dependencies added: QuickCheck
Dependency ranges changed: base, numhask, text, time, vector
Files
- numhask-space.cabal +17/−8
- src/NumHask/Space/Point.hs +5/−3
- src/NumHask/Space/Range.hs +7/−6
- src/NumHask/Space/Time.hs +2/−11
- test/doctests.hs +8/−0
numhask-space.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: numhask-space-version: 0.10.0.0+version: 0.10.0.1 synopsis: Numerical spaces. description: @numhask-space@ provides support for spaces where [space](https://en.wikipedia.org/wiki/Space_(mathematics\)) is defined as a set of numbers with a lower and upper bound.@@ -21,7 +21,8 @@ license: BSD-3-Clause license-file: LICENSE build-type: Simple-tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.2.1+tested-with:+ GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.2.5 || ==9.4.4 extra-source-files: ChangeLog.md source-repository head@@ -32,8 +33,7 @@ hs-source-dirs: src ghc-options: -Wall -Wcompat -Wincomplete-record-updates- -Wincomplete-uni-patterns -Wredundant-constraints -fwrite-ide-info- -hiedir=.hie+ -Wincomplete-uni-patterns -Wredundant-constraints default-extensions: build-depends:@@ -41,13 +41,13 @@ , base >=4.7 && <5 , containers ^>=0.6 , distributive >=0.2.2 && <1- , numhask ^>=0.10.0+ , numhask >=0.10.0 && <0.11 , random ^>=1.2 , semigroupoids >=5 && <5.4 , tdigest ^>=0.2.1- , text >=1.2.3.1 && <2- , time >=1.9.1 && <1.12- , vector ^>=0.12+ , text >=1.2.3.1 && <3+ , time >=1.9.1 && <1.13+ , vector >=0.12 && <0.14 exposed-modules: NumHask.Space@@ -60,3 +60,12 @@ other-modules: default-language: Haskell2010++test-suite doctests+ type: exitcode-stdio-1.0+ main-is: doctests.hs+ hs-source-dirs: test+ default-language: Haskell2010+ build-depends:+ , base+ , QuickCheck
src/NumHask/Space/Point.hs view
@@ -102,7 +102,7 @@ instance (Semigroup a) => Semigroup (Point a) where (Point a0 b0) <> (Point a1 b1) = Point (a0 <> a1) (b0 <> b1) -instance (Semigroup a, Monoid a) => Monoid (Point a) where+instance (Monoid a) => Monoid (Point a) where mempty = Point mempty mempty mappend = (<>)@@ -258,8 +258,10 @@ let dy = y1 - y2 dx = x2 - x1 d = sqrt (dx * dx + dy * dy)- in dy `seq` dx `seq` d- `seq` \(Point x y) -> (x - x1) * dy / d + (y - y1) * dx / d+ in dy `seq`+ dx `seq`+ d `seq`+ \(Point x y) -> (x - x1) * dy / d + (y - y1) * dx / d -- | Return the point on the line closest to the given point. closestPoint :: (Field a) => Line a -> Point a -> Point a
src/NumHask/Space/Range.hs view
@@ -6,6 +6,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- | A Space containing numerical elements module NumHask.Space.Range@@ -115,7 +116,7 @@ instance (Ord a) => MeetSemiLattice (Range a) where (/\) = liftR2 max -instance (Eq a, Ord a) => Space (Range a) where+instance (Ord a) => Space (Range a) where type Element (Range a) = a lower (Range l _) = l@@ -143,17 +144,17 @@ ps = grid OuterPos r n -- | Monoid based on convex hull union-instance (Eq a, Ord a) => Semigroup (Range a) where+instance (Ord a) => Semigroup (Range a) where (<>) a b = getUnion (Union a <> Union b) -instance (Additive a, Eq a, Ord a) => Additive (Range a) where+instance (Additive a, Ord a) => Additive (Range a) where (Range l u) + (Range l' u') = unsafeSpace1 [l + l', u + u'] zero = Range zero zero -instance (Subtractive a, Eq a, Ord a) => Subtractive (Range a) where+instance (Subtractive a, Ord a) => Subtractive (Range a) where negate (Range l u) = negate u ... negate l -instance (Field a, Eq a, Ord a) => Multiplicative (Range a) where+instance (Field a, Ord a) => Multiplicative (Range a) where a * b = bool (Range (m - r / (one + one)) (m + r / (one + one))) zero (a == zero || b == zero) where m = mid a + mid b@@ -167,7 +168,7 @@ m = mid a r = width a -instance (Field a, Subtractive a, Eq a, Ord a) => Signed (Range a) where+instance (Field a, Ord a) => Signed (Range a) where sign (Range l u) = bool (negate one) one (u >= l) abs (Range l u) = bool (u ... l) (l ... u) (u >= l)
src/NumHask/Space/Time.hs view
@@ -9,8 +9,7 @@ -- | data algorithms related to time (as a Space) module NumHask.Space.Time- ( parseUTCTime,- TimeGrain (..),+ ( TimeGrain (..), floorGrain, ceilingGrain, addGrain,@@ -44,14 +43,6 @@ -- -- > :set -XOverloadedStrings --- | parse text as per iso8601------ >>> parseUTCTime (pack "2017-12-05")--- Just 2017-12-05 00:00:00 UTC-parseUTCTime :: Text -> Maybe UTCTime-parseUTCTime =- parseTimeM False defaultTimeLocale (iso8601DateFormat Nothing) . unpack- -- | a step in time data TimeGrain = Years Integer@@ -270,7 +261,7 @@ | x > 3 = "%d/%m/%y %R" | otherwise = "%R" autoFormat (Minutes _) = "%R"-autoFormat (Seconds _) = "%R%Q"+autoFormat (Seconds _) = "%T%Q" laterTimes :: [(Int, a)] -> [(Int, a)] laterTimes [] = []
+ test/doctests.hs view
@@ -0,0 +1,8 @@+module Main where++main :: IO ()+main = do+ putStrLn "This test-suite exists only to add dependencies"+ putStrLn "To run doctests: "+ putStrLn " cabal build all --enable-tests"+ putStrLn " cabal-docspec"