numhask-space-0.3.1: numerical spaces

Safe HaskellSafe
LanguageHaskell2010

NumHask.Space.Range

Description

A Space containing numerical elements

Synopsis

Documentation

data Range a Source #

A continuous range over type a

>>> let a = Range (-1) 1
>>> a
Range -1 1

Num instance based on interval arithmetic (with Ranges normalising to lower ... upper)

>>> a + a
Range -2 2
>>> a * a
Range -1 1
>>> (+1) <$> (Range 1 2)
Range 2 3

Ranges are very useful in shifting a bunch of numbers from one Range to another. eg project 0.5 from the range 0 to 1 to the range 1 to 4

>>> project (Range 0 1) (Range 1 4) 0.5
2.5

Create an equally spaced grid including outer bounds over a Range

>>> grid OuterPos (Range 0 10) 5
[0.0,2.0,4.0,6.0,8.0,10.0]

divide up a Range into equal-sized sections

>>> gridSpace (Range 0 1) 4
[Range 0.0 0.25,Range 0.25 0.5,Range 0.5 0.75,Range 0.75 1.0]

Constructors

Range a a 
Instances
Functor Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

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

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

Applicative Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

pure :: a -> Range a #

(<*>) :: Range (a -> b) -> Range a -> Range b #

liftA2 :: (a -> b -> c) -> Range a -> Range b -> Range c #

(*>) :: Range a -> Range b -> Range b #

(<*) :: Range a -> Range b -> Range a #

Foldable Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

fold :: Monoid m => Range m -> m #

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

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

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

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

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

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

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

toList :: Range a -> [a] #

null :: Range a -> Bool #

length :: Range a -> Int #

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

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

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

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

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

Traversable Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

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

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

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

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

Distributive Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

distribute :: Functor f => f (Range a) -> Range (f a) #

collect :: Functor f => (a -> Range b) -> f a -> Range (f b) #

distributeM :: Monad m => m (Range a) -> Range (m a) #

collectM :: Monad m => (a -> Range b) -> m a -> Range (m b) #

Representable Range Source # 
Instance details

Defined in NumHask.Space.Range

Associated Types

type Rep Range :: Type #

Methods

tabulate :: (Rep Range -> a) -> Range a #

index :: Range a -> Rep Range -> a #

Eq1 Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

liftEq :: (a -> b -> Bool) -> Range a -> Range b -> Bool #

Show1 Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Range a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Range a] -> ShowS #

Apply Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

(<.>) :: Range (a -> b) -> Range a -> Range b #

(.>) :: Range a -> Range b -> Range b #

(<.) :: Range a -> Range b -> Range a #

liftF2 :: (a -> b -> c) -> Range a -> Range b -> Range c #

Foldable1 Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

fold1 :: Semigroup m => Range m -> m #

foldMap1 :: Semigroup m => (a -> m) -> Range a -> m #

toNonEmpty :: Range a -> NonEmpty a #

Traversable1 Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

traverse1 :: Apply f => (a -> f b) -> Range a -> f (Range b) #

sequence1 :: Apply f => Range (f b) -> f (Range b) #

Eq a => Eq (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Methods

(==) :: Range a -> Range a -> Bool #

(/=) :: Range a -> Range a -> Bool #

(Num a, Eq a, Ord a) => Num (Range a) Source #

Numeric algebra based on Interval arithmetic

Instance details

Defined in NumHask.Space.Range

Methods

(+) :: Range a -> Range a -> Range a #

(-) :: Range a -> Range a -> Range a #

(*) :: Range a -> Range a -> Range a #

negate :: Range a -> Range a #

abs :: Range a -> Range a #

signum :: Range a -> Range a #

fromInteger :: Integer -> Range a #

Show a => Show (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Methods

showsPrec :: Int -> Range a -> ShowS #

show :: Range a -> String #

showList :: [Range a] -> ShowS #

Generic (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Associated Types

type Rep (Range a) :: Type -> Type #

Methods

from :: Range a -> Rep (Range a) x #

to :: Rep (Range a) x -> Range a #

(Eq a, Ord a) => Semigroup (Range a) Source #

Monoid based on convex hull union

Instance details

Defined in NumHask.Space.Range

Methods

(<>) :: Range a -> Range a -> Range a #

sconcat :: NonEmpty (Range a) -> Range a #

stimes :: Integral b => b -> Range a -> Range a #

Ord a => Lattice (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Methods

(\/) :: Range a -> Range a -> Range a #

(/\) :: Range a -> Range a -> Range a #

(Ord a, Fractional a) => FieldSpace (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Associated Types

type Grid (Range a) :: Type Source #

Methods

grid :: Pos -> Range a -> Grid (Range a) -> [Element (Range a)] Source #

gridSpace :: Range a -> Grid (Range a) -> [Range a] Source #

(Eq a, Ord a) => Space (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Associated Types

type Element (Range a) :: Type Source #

type Rep Range Source # 
Instance details

Defined in NumHask.Space.Range

type Rep Range = Bool
type Rep (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

type Rep (Range a) = D1 (MetaData "Range" "NumHask.Space.Range" "numhask-space-0.3.1-FBHjcudLGMs5p7nA3Cfrcy" False) (C1 (MetaCons "Range" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Grid (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

type Grid (Range a) = Int
type Element (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

type Element (Range a) = a

gridSensible :: (Ord a, RealFrac a, Floating a, Integral b) => Pos -> Bool -> Range a -> b -> [a] Source #

a grid with human sensible (rounded) values

>>> gridSensible OuterPos False (Range (-12.0) 23.0) 6
[-15.0,-10.0,-5.0,0.0,5.0,10.0,15.0,20.0,25.0]