hgeometry-0.6.0.0: Geometric Algorithms, Data structures, and Data types.

Safe HaskellNone
LanguageHaskell2010

Data.Geometry.Interval

Contents

Synopsis

1 dimensional Intervals

newtype Interval a r Source #

An Interval is essentially a Range but with possible payload

Constructors

GInterval 

Fields

Instances

Bifunctor Interval Source # 

Methods

bimap :: (a -> b) -> (c -> d) -> Interval a c -> Interval b d #

first :: (a -> b) -> Interval a c -> Interval b c #

second :: (b -> c) -> Interval a b -> Interval a c #

Functor (Interval a) Source # 

Methods

fmap :: (a -> b) -> Interval a a -> Interval a b #

(<$) :: a -> Interval a b -> Interval a a #

Foldable (Interval a) Source # 

Methods

fold :: Monoid m => Interval a m -> m #

foldMap :: Monoid m => (a -> m) -> Interval a a -> m #

foldr :: (a -> b -> b) -> b -> Interval a a -> b #

foldr' :: (a -> b -> b) -> b -> Interval a a -> b #

foldl :: (b -> a -> b) -> b -> Interval a a -> b #

foldl' :: (b -> a -> b) -> b -> Interval a a -> b #

foldr1 :: (a -> a -> a) -> Interval a a -> a #

foldl1 :: (a -> a -> a) -> Interval a a -> a #

toList :: Interval a a -> [a] #

null :: Interval a a -> Bool #

length :: Interval a a -> Int #

elem :: Eq a => a -> Interval a a -> Bool #

maximum :: Ord a => Interval a a -> a #

minimum :: Ord a => Interval a a -> a #

sum :: Num a => Interval a a -> a #

product :: Num a => Interval a a -> a #

Traversable (Interval a) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Interval a a -> f (Interval a b) #

sequenceA :: Applicative f => Interval a (f a) -> f (Interval a a) #

mapM :: Monad m => (a -> m b) -> Interval a a -> m (Interval a b) #

sequence :: Monad m => Interval a (m a) -> m (Interval a a) #

(Eq r, Eq a) => Eq (Interval a r) Source # 

Methods

(==) :: Interval a r -> Interval a r -> Bool #

(/=) :: Interval a r -> Interval a r -> Bool #

(Show a, Show r) => Show (Interval a r) Source # 

Methods

showsPrec :: Int -> Interval a r -> ShowS #

show :: Interval a r -> String #

showList :: [Interval a r] -> ShowS #

Generic (Interval a r) Source # 

Associated Types

type Rep (Interval a r) :: * -> * #

Methods

from :: Interval a r -> Rep (Interval a r) x #

to :: Rep (Interval a r) x -> Interval a r #

(NFData a, NFData r) => NFData (Interval a r) Source # 

Methods

rnf :: Interval a r -> () #

HasEnd (Interval a r) Source # 

Associated Types

type EndCore (Interval a r) :: * Source #

type EndExtra (Interval a r) :: * Source #

Methods

end :: Lens' (Interval a r) (EndCore (Interval a r) :+ EndExtra (Interval a r)) Source #

HasStart (Interval a r) Source # 

Associated Types

type StartCore (Interval a r) :: * Source #

type StartExtra (Interval a r) :: * Source #

IntervalLike (Interval p r) Source # 

Methods

toRange :: Interval p r -> Range (NumType (Interval p r)) Source #

Ord r => IsIntersectableWith (Interval a r) (Interval a r) Source # 

Methods

intersect :: Interval a r -> Interval a r -> Intersection (Interval a r) (Interval a r) Source #

intersects :: Interval a r -> Interval a r -> Bool Source #

nonEmptyIntersection :: proxy (Interval a r) -> proxy (Interval a r) -> Intersection (Interval a r) (Interval a r) -> Bool Source #

type Rep (Interval a r) Source # 
type Rep (Interval a r) = D1 (MetaData "Interval" "Data.Geometry.Interval" "hgeometry-0.6.0.0-ODn7ZyBfwj6IkLPAAzetJ" True) (C1 (MetaCons "GInterval" PrefixI True) (S1 (MetaSel (Just Symbol "_unInterval") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Range ((:+) r a)))))
type NumType (Interval a r) Source # 
type NumType (Interval a r) = r
type Dimension (Interval a r) Source # 
type Dimension (Interval a r) = 1
type EndCore (Interval a r) Source # 
type EndCore (Interval a r) = r
type EndExtra (Interval a r) Source # 
type EndExtra (Interval a r) = a
type StartCore (Interval a r) Source # 
type StartCore (Interval a r) = r
type StartExtra (Interval a r) Source # 
type StartExtra (Interval a r) = a
type IntersectionOf (Interval a r) (Interval a r) Source # 
type IntersectionOf (Interval a r) (Interval a r) = (:) * NoIntersection ((:) * (Interval a r) ([] *))

pattern OpenInterval :: forall r a. (:+) r a -> (:+) r a -> Interval a r Source #

pattern ClosedInterval :: forall r a. (:+) r a -> (:+) r a -> Interval a r Source #

pattern Interval :: forall r a. EndPoint ((:+) r a) -> EndPoint ((:+) r a) -> Interval a r Source #

querying the start and end of intervals

class HasStart t where Source #

Minimal complete definition

start

Associated Types

type StartCore t Source #

type StartExtra t Source #

Instances

HasStart (Interval a r) Source # 

Associated Types

type StartCore (Interval a r) :: * Source #

type StartExtra (Interval a r) :: * Source #

HasStart (HalfLine d r) Source # 

Associated Types

type StartCore (HalfLine d r) :: * Source #

type StartExtra (HalfLine d r) :: * Source #

HasStart (LineSegment d p r) Source # 

Associated Types

type StartCore (LineSegment d p r) :: * Source #

type StartExtra (LineSegment d p r) :: * Source #

class HasEnd t where Source #

Minimal complete definition

end

Associated Types

type EndCore t Source #

type EndExtra t Source #

Methods

end :: Lens' t (EndCore t :+ EndExtra t) Source #

Instances

HasEnd (Interval a r) Source # 

Associated Types

type EndCore (Interval a r) :: * Source #

type EndExtra (Interval a r) :: * Source #

Methods

end :: Lens' (Interval a r) (EndCore (Interval a r) :+ EndExtra (Interval a r)) Source #

HasEnd (LineSegment d p r) Source # 

Associated Types

type EndCore (LineSegment d p r) :: * Source #

type EndExtra (LineSegment d p r) :: * Source #

Methods

end :: Lens' (LineSegment d p r) (EndCore (LineSegment d p r) :+ EndExtra (LineSegment d p r)) Source #

Working with intervals

inInterval :: Ord r => r -> Interval a r -> Bool Source #

Test if a value lies in an interval. Note that the difference between inInterval and inRange is that the extra value is *not* used in the comparison with inInterval, whereas it is in inRange.

shiftLeft' :: Num r => r -> Interval a r -> Interval a r Source #

module Data.Range