packages feed

range-space 0.1.0.4 → 0.1.1.0

raw patch · 2 files changed

+21/−21 lines, 2 filesdep +semigroupsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: semigroups

API changes (from Hackage documentation)

+ Data.RangeSpace: instance (BasisRange t) => Semigroup (Range t)
- Data.RangeSpace: inRange :: (Ord a, AffineSpace a, HasBasis (Diff a), Eq (Basis (Diff a)), Num (Scalar (Diff a)), Ord (Scalar (Diff a))) => a -> Range a -> Bool
+ Data.RangeSpace: inRange :: (BasisRange a, Eq (Basis (Diff a))) => a -> Range a -> Bool
- Data.RangeSpace: maskRange :: (Eq (Basis (Diff t)), Num (Scalar (Diff t)), Ord t, Ord (Scalar (Diff t)), HasBasis (Diff t), AffineSpace t) => Range t -> Range t -> Range t
+ Data.RangeSpace: maskRange :: (Eq (Basis (Diff t)), BasisRange t) => Range t -> Range t -> Range t
- Data.RangeSpace: newRange :: (Ord t, AffineSpace t, HasBasis (Diff t), Ord (Scalar (Diff t)), Num (Scalar (Diff t))) => t -> t -> Range t
+ Data.RangeSpace: newRange :: BasisRange t => t -> t -> Range t
- Data.RangeSpace: unionBounds :: (Num (Scalar (Diff t)), Ord (Scalar (Diff t)), Ord t, HasBasis (Diff t), AffineSpace t) => Bounds t -> Bounds t -> Bounds t
+ Data.RangeSpace: unionBounds :: BasisRange t => Bounds t -> Bounds t -> Bounds t
- Data.RangeSpace: unionRange :: (Num (Scalar (Diff t)), Ord t, Ord (Scalar (Diff t)), HasBasis (Diff t), AffineSpace t) => Range t -> Range t -> Range t
+ Data.RangeSpace: unionRange :: BasisRange t => Range t -> Range t -> Range t

Files

Data/RangeSpace.hs view
@@ -1,7 +1,9 @@+{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE UndecidableInstances #-}  ---------------------------------------------------------------------- {- |@@ -72,6 +74,7 @@  import Control.Applicative import Control.Arrow             ((***))+import Data.Semigroup import Data.List                 (zipWith4)  #if MIN_VERSION_vector_space_points(0,1,2)@@ -92,6 +95,9 @@     pure a = Range a a     (Range minf maxf) <*> (Range minv maxv) = Range (minf minv) (maxf maxv) +instance (BasisRange t) => Semigroup (Range t) where+    (<>) = unionRange+ -- | A '(minimum,maximum)' pair type Bounds t = (t,t) @@ -152,21 +158,17 @@ -- ------------------------------------------------------------------------- -- multi-dimensional stuff +-- | The necessary 'Constraint' for working with multi-dimensional ranges.+type BasisRange t = (Ord t, AffineSpace t, HasBasis (Diff t)+                    ,Ord (Scalar (Diff t)), Num (Scalar (Diff t)))+ -- | Create a range from a 'start,stop' pair.  For multi-dimensional ranges, -- the resulting range will be the union of the two points.-newRange :: (Ord t, AffineSpace t, HasBasis (Diff t)-            ,Ord (Scalar (Diff t)), Num (Scalar (Diff t)))-         => t-         -> t-         -> Range t+newRange :: BasisRange t => t -> t -> Range t newRange start stop = unionRange (Range start start) (Range stop stop)  -- | Calculate the union of two 'Bounds'.  See the notes for @unionRange@.-unionBounds :: (Num (Scalar (Diff t)), Ord (Scalar (Diff t)), Ord t,-               HasBasis (Diff t), AffineSpace t)-            => Bounds t-            -> Bounds t-            -> Bounds t+unionBounds :: BasisRange t => Bounds t -> Bounds t -> Bounds t unionBounds r1 r2 = unRange $ unionRange (fromBounds r1) (fromBounds r2)  -- | Calculate the union of two 'Range's, per-basis.@@ -180,14 +182,12 @@ -- doesn't require a full 'VectorSpace'. It does require that the -- affine space scalars are in a vector space, but this is more easily -- satisfiable.-unionRange :: (Num (Scalar (Diff t)), Ord t, Ord (Scalar (Diff t)),-                HasBasis (Diff t), AffineSpace t)-           => Range t -> Range t -> Range t+unionRange :: BasisRange t => Range t -> Range t -> Range t unionRange r0 r1 =         Range (adjust combineMin min0 min1) (adjust combineMax max0 max1)     where-        combineMin diff = min diff 0-        combineMax diff = max diff 0+        combineMin dif = min dif 0+        combineMax dif = max dif 0         adjust f orig s = (orig .+^) . recompose . map (fmap f)                              . decompose $ s .-. orig         (min0,max0) = toBounds r0@@ -199,8 +199,7 @@ --  independently for each basis. --  If the range lies entirely outside the mask, the returned value --  is 'Range rmin rmin' (per-basis)-maskRange :: (Eq (Basis (Diff t)), Num (Scalar (Diff t)), Ord t,-                   Ord (Scalar (Diff t)), HasBasis (Diff t), AffineSpace t)+maskRange :: (Eq (Basis (Diff t)), BasisRange t)               => Range t    -- ^ restriction               -> Range t    -- ^ original Range               -> Range t@@ -249,8 +248,7 @@ -- -------------------------------------------------------------------------  -- | True if a value lies inside a 'Range'.-inRange :: (Ord a, AffineSpace a, HasBasis (Diff a), Eq (Basis (Diff a))-           ,Num (Scalar (Diff a)) ,Ord (Scalar (Diff a)))+inRange :: (BasisRange a, Eq (Basis (Diff a)))         => a         -> Range a         -> Bool
range-space.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                range-space-version:             0.1.0.4+version:             0.1.1.0 synopsis:            A Range type with vector-space instances description:         Provides functions for converting between ranges and spans homepage:            https://github.com/JohnLato/range-space@@ -22,6 +22,7 @@                        Data.RangeSpace.TwoD   -- other-modules:          build-depends:       base >= 4.5 && < 5+                      ,semigroups   >= 0.8 && < 0.10                       ,vector-space == 0.8.*                       ,vector-space-points == 0.1.*   default-extensions: CPP@@ -31,11 +32,12 @@   type: exitcode-stdio-1.0   main-is: Properties.hs   hs-source-dirs: tests .-  ghc-options:    -fhpc -hpcdir dist/hpc/mix/range-space-0.1.0.4+  ghc-options:    -fhpc -hpcdir dist/hpc/mix/range-space-0.1.1.0    build-depends:       base,       range-space,+      semigroups,       vector-space,       vector-space-points,       time                       == 1.4.*,