numhask-space 0.13.2.0 → 0.13.3.0
raw patch · 5 files changed
+62/−62 lines, 5 filesdep ~timePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: time
API changes (from Hackage documentation)
+ NumHask.Space.Point: instance GHC.Read.Read a => GHC.Read.Read (NumHask.Space.Point.Point a)
+ NumHask.Space.Range: instance GHC.Read.Read a => GHC.Read.Read (NumHask.Space.Range.Range a)
+ NumHask.Space.Rect: instance GHC.Read.Read a => GHC.Read.Read (NumHask.Space.Rect.Rect a)
Files
- ChangeLog.md +7/−55
- numhask-space.cabal +4/−5
- src/NumHask/Space/Point.hs +22/−0
- src/NumHask/Space/Range.hs +4/−1
- src/NumHask/Space/Rect.hs +25/−1
ChangeLog.md view
@@ -1,57 +1,9 @@-0.13.1.1-===-- GHC 9.14 support--0.13.1-===-- added Data instances---0.13-===-- removed randomS, randomSM, randomSs-- removed random dependency--0.12-==-* rx,ry,rz,rw added to NumHask.Space.Rect--0.11.1.0-===-* Rect and Point show instances include negative brackets.-* removed NegativeLiterals as a requirement.--0.11.0.0-===-* fixes for numhask-0.11--0.9.0-===-* added emptyHistogram-* fixes for numhask-0.9--0.8.2-===-* replaced space1 partial with unsafeSpace1 + total space1--0.8.1-===-* GHC 9.0.1 support-* API fixes for random-1.2; `randomS`, `randomSM` & `randomSs` --0.7.0-=====--* GHC 8.10.2 support-* Added `Transform` and `Affinity` capabilities-* Added `Line` and associated functions.-* Support for random-1.2; `uniformS` and `uniformSs`-* Shifted to zero-centered, width scaling `Range` multiplication.-* Added `average` & `quantile` to NumHask.Space.Histogram-* Improved haddocks-* Extended doctests+# Changelog -0.6.1-=====+## 0.13.3.0 -* GHC 8.10.1 support+- Fixed `Show`/`Read` mismatch for `Point`, `Rect` and `Range` by adding+ `showsPrec` implementations that parenthesise values when precedence is+ greater than function-application precedence.+- Added `Read` instances for `Point` and `Rect`.+- Relaxed the upper bound on `time` to `<1.17`.
numhask-space.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: numhask-space-version: 0.13.2.0+version: 0.13.3.0 license: BSD-3-Clause license-file: LICENSE copyright: Tony Day (c) 2016@@ -21,11 +21,11 @@ build-type: Simple tested-with:- ghc ==9.6.7- ghc ==9.8.4 ghc ==9.10.2 ghc ==9.12.2 ghc ==9.14.1+ ghc ==9.6.7+ ghc ==9.8.4 extra-doc-files: ChangeLog.md @@ -76,7 +76,7 @@ semigroupoids >=5.3 && <6.1, tdigest >=0.2.1 && <0.4, text >=1.2 && <2.2,- time >=1.9.1 && <1.16,+ time >=1.9.1 && <1.17, vector >=0.12.3 && <0.14, exposed-modules:@@ -87,4 +87,3 @@ NumHask.Space.Rect NumHask.Space.Time NumHask.Space.Types-
src/NumHask/Space/Point.hs view
@@ -69,6 +69,28 @@ show (Point a b) = "Point " <> wrap a <> " " <> wrap b where wrap x = bool (show x) ("(" <> show x <> ")") (x < zero)+ showsPrec d p = showParen (d > app_prec) (showString (show p))+ where+ app_prec = 10++instance (Read a) => Read (Point a) where+ readsPrec d s = readParen (d > app_prec) parsePoint s+ where+ app_prec = 10+ parsePoint r = do+ ("Point", r1) <- lex r+ (x, r2) <- readsMaybeNeg r1+ (y, r3) <- readsMaybeNeg r2+ pure (Point x y, r3)+ readsMaybeNeg t = case reads t of+ [(v, rest)] -> [(v, rest)]+ [] -> case t of+ '(' : r0 -> case reads r0 of+ [(v, rest)] -> case rest of+ ')' : r -> [(v, r)]+ _ -> []+ _ -> []+ _ -> [] instance Functor Point where fmap f (Point a b) = Point (f a) (f b)
src/NumHask/Space/Range.hs view
@@ -57,13 +57,16 @@ -- >>> gridSpace (Range 0.0 1.0) 4 -- [Range 0.0 0.25,Range 0.25 0.5,Range 0.5 0.75,Range 0.75 1.0] data Range a = Range a a- deriving (Eq, Generic, Data)+ deriving (Eq, Read, Generic, Data) instance Eq1 Range where liftEq f (Range a b) (Range c d) = f a c && f b d instance (Show a) => Show (Range a) where show (Range a b) = "Range " <> show a <> " " <> show b+ showsPrec d p = showParen (d > app_prec) (showString (show p))+ where+ app_prec = 10 instance Functor Range where fmap f (Range a b) = Range (f a) (f b)
src/NumHask/Space/Rect.hs view
@@ -109,7 +109,31 @@ "Rect " <> wrap a <> " " <> wrap b <> " " <> wrap c <> " " <> wrap d where wrap x = bool (show x) ("(" <> show x <> ")") (x < zero)+ showsPrec d p = showParen (d > app_prec) (showString (show p))+ where+ app_prec = 10 +instance (Read a) => Read (Rect a) where+ readsPrec d s = readParen (d > app_prec) parseRect s+ where+ app_prec = 10+ parseRect r = do+ ("Rect", r1) <- lex r+ (a, r2) <- readsMaybeNeg r1+ (b, r3) <- readsMaybeNeg r2+ (c, r4) <- readsMaybeNeg r3+ (d, r5) <- readsMaybeNeg r4+ pure (Rect a b c d, r5)+ readsMaybeNeg t = case reads t of+ [(v, rest)] -> [(v, rest)]+ [] -> case t of+ '(' : r0 -> case reads r0 of+ [(v, rest)] -> case rest of+ ')' : r -> [(v, r)]+ _ -> []+ _ -> []+ _ -> []+ instance Distributive Rect where collect f x = Rect (getA . f <$> x) (getB . f <$> x) (getC . f <$> x) (getD . f <$> x)@@ -285,7 +309,7 @@ -- | convex hull union of Rect's -- -- >>> foldRect [Rect 0 1 0 1, one]--- Just Rect (-0.5) 1.0 (-0.5) 1.0+-- Just (Rect (-0.5) 1.0 (-0.5) 1.0) foldRect :: (Ord a) => [Rect a] -> Maybe (Rect a) foldRect [] = Nothing foldRect (x : xs) = Just $ sconcat (x :| xs)