hgeometry-combinatorial
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageGHC2021

HGeometry.Number.Real.Rational

Description

 
Synopsis

Documentation

newtype RealNumber (p :: Nat) Source #

Real Numbers represented using Rational numbers. The number type itself is exact in the sense that we can represent any rational number.

The parameter, a natural number, represents the precision (in number of decimals behind the period) with which we display the numbers when printing them (using Show).

If the number cannot be displayed exactly a ~ is printed after the number.

Constructors

RealNumber Rational 

Instances

Instances details
FromJSON (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

ToJSON (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

NFData (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Methods

rnf :: RealNumber p -> () #

KnownNat p => Data (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RealNumber p -> c (RealNumber p) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (RealNumber p) #

toConstr :: RealNumber p -> Constr #

dataTypeOf :: RealNumber p -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (RealNumber p)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (RealNumber p)) #

gmapT :: (forall b. Data b => b -> b) -> RealNumber p -> RealNumber p #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RealNumber p -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RealNumber p -> r #

gmapQ :: (forall d. Data d => d -> u) -> RealNumber p -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> RealNumber p -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RealNumber p -> m (RealNumber p) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RealNumber p -> m (RealNumber p) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RealNumber p -> m (RealNumber p) #

Generic (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Associated Types

type Rep (RealNumber p) 
Instance details

Defined in HGeometry.Number.Real.Rational

type Rep (RealNumber p) = D1 ('MetaData "RealNumber" "HGeometry.Number.Real.Rational" "hgeometry-combinatorial-1.0.0.0-inplace" 'True) (C1 ('MetaCons "RealNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational)))

Methods

from :: RealNumber p -> Rep (RealNumber p) x #

to :: Rep (RealNumber p) x -> RealNumber p #

Num (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

KnownNat p => Read (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Fractional (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Real (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

RealFrac (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Methods

properFraction :: Integral b => RealNumber p -> (b, RealNumber p) #

truncate :: Integral b => RealNumber p -> b #

round :: Integral b => RealNumber p -> b #

ceiling :: Integral b => RealNumber p -> b #

floor :: Integral b => RealNumber p -> b #

KnownNat p => Show (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Eq (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Methods

(==) :: RealNumber p -> RealNumber p -> Bool #

(/=) :: RealNumber p -> RealNumber p -> Bool #

Ord (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Random (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Methods

randomR :: RandomGen g => (RealNumber p, RealNumber p) -> g -> (RealNumber p, g) Source #

random :: RandomGen g => g -> (RealNumber p, g) Source #

randomRs :: RandomGen g => (RealNumber p, RealNumber p) -> g -> [RealNumber p] Source #

randoms :: RandomGen g => g -> [RealNumber p] Source #

type Rep (RealNumber p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

type Rep (RealNumber p) = D1 ('MetaData "RealNumber" "HGeometry.Number.Real.Rational" "hgeometry-combinatorial-1.0.0.0-inplace" 'True) (C1 ('MetaCons "RealNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational)))

Converting to and from RealNumber's

data AsFixed (p :: k) Source #

Fixed-precision representation of a RealNumber. If there's insufficient precision to accurately represent the RealNumber then the Lossy constructor will be used.

Constructors

Exact !(Fixed p) 
Lossy !(Fixed p) 

Instances

Instances details
HasResolution p => Show (AsFixed p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Methods

showsPrec :: Int -> AsFixed p -> ShowS #

show :: AsFixed p -> String #

showList :: [AsFixed p] -> ShowS #

Eq (AsFixed p) Source # 
Instance details

Defined in HGeometry.Number.Real.Rational

Methods

(==) :: AsFixed p -> AsFixed p -> Bool #

(/=) :: AsFixed p -> AsFixed p -> Bool #

asFixed :: forall (p :: Nat). KnownNat p => RealNumber p -> AsFixed (NatPrec p) Source #

Cast RealNumber to a fixed-precision number. Data-loss caused by insufficient precision will be marked by the Lossy constructor.

toFixed :: forall (p :: Nat). KnownNat p => RealNumber p -> Fixed (NatPrec p) Source #

Cast RealNumber to a fixed-precision number. Data is silently lost if there's insufficient precision.

fromFixed :: forall (p :: Nat). KnownNat p => Fixed (NatPrec p) -> RealNumber p Source #

Cast a fixed-precision number to a RealNumber.

type Nat = Natural #

A type synonym for Natural.

Previously, this was an opaque data type, but it was changed to a type synonym.

@since base-4.16.0.0