numhask-space-0.11.1.0: Numerical spaces.
Safe HaskellSafe-Inferred
LanguageGHC2021

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
>>> a + a
Range -2 2
>>> a * a
Range -2.0 2.0
>>> (+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.0 10.0) 5
[0.0,2.0,4.0,6.0,8.0,10.0]

divide up a Range into equal-sized sections

>>> 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]

Constructors

Range a a 

Instances

Instances details
Representable Range Source # 
Instance details

Defined in NumHask.Space.Range

Associated Types

type Rep Range #

Methods

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

index :: Range a -> Rep 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 #

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 #

Eq1 Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

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

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) #

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 #

Functor Range Source # 
Instance details

Defined in NumHask.Space.Range

Methods

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

(<$) :: a -> Range b -> 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) #

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 #

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 #

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 #

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 #

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

Defined in NumHask.Space.Range

Methods

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

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

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

Defined in NumHask.Space.Range

Methods

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

zero :: Range a #

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

Defined in NumHask.Space.Range

Methods

negate :: Range a -> Range a #

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

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

Defined in NumHask.Space.Range

Methods

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

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

Defined in NumHask.Space.Range

Methods

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

(Field a, Ord a) => Basis (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Associated Types

type Mag (Range a) #

type Base (Range a) #

Methods

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

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

(Ord a, Field a) => Divisive (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Methods

recip :: Range a -> Range a #

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

(Field a, Ord a) => Multiplicative (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Methods

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

one :: Range a #

(Field a, Ord a, FromIntegral a Int) => FieldSpace (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

Associated Types

type Grid (Range a) Source #

Methods

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

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

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

Defined in NumHask.Space.Range

Associated Types

type Element (Range a) 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.11.1.0-CGZkWl1dCI0Hh4RFyxzImX" '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 Base (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

type Base (Range a) = a
type Mag (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

type Mag (Range a) = Range a
type Element (Range a) Source # 
Instance details

Defined in NumHask.Space.Range

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

Defined in NumHask.Space.Range

type Grid (Range a) = Int

gridSensible :: Pos -> Bool -> Range Double -> Int -> [Double] Source #

a grid for five-digits per limb species

>>> 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]