ivory-0.1.0.6: Safe embedded C programming.

Safe HaskellNone
LanguageHaskell2010

Ivory.Language.Cast

Description

Safe casting. We assume Floats have 32 bits and Doubles have 64.

Synopsis

Documentation

safeCast :: SafeCast from to => from -> to Source #

ivoryCast :: forall a b. (IvoryExpr a, IvoryExpr b) => a -> b Source #

castWith :: RuntimeCast from to => to -> from -> to Source #

Cast with a default value if the casted value is too large.

castDefault :: (Default to, RuntimeCast from to) => from -> to Source #

`CastWith 0` for types for which 0 is defined.

signCast :: SignCast from to => from -> to Source #

class (IvoryExpr from, IvoryExpr to) => SafeCast from to where Source #

Statically safe casts.

Methods

safeCast :: from -> to Source #

Instances

SafeCast IChar IChar Source # 

Methods

safeCast :: IChar -> IChar Source #

SafeCast Sint64 Sint64 Source # 
SafeCast Sint64 IDouble Source # 
SafeCast Sint32 Sint64 Source # 
SafeCast Sint32 Sint32 Source # 
SafeCast Sint32 IDouble Source # 
SafeCast Sint32 IFloat Source # 
SafeCast Sint16 Sint64 Source # 
SafeCast Sint16 Sint32 Source # 
SafeCast Sint16 Sint16 Source # 
SafeCast Sint16 IDouble Source # 
SafeCast Sint16 IFloat Source # 
SafeCast Sint8 Sint64 Source # 
SafeCast Sint8 Sint32 Source # 
SafeCast Sint8 Sint16 Source # 
SafeCast Sint8 Sint8 Source # 

Methods

safeCast :: Sint8 -> Sint8 Source #

SafeCast Sint8 IDouble Source # 
SafeCast Sint8 IFloat Source # 
SafeCast Uint64 Uint64 Source # 
SafeCast Uint64 IDouble Source # 
SafeCast Uint32 Sint64 Source # 
SafeCast Uint32 Uint64 Source # 
SafeCast Uint32 Uint32 Source # 
SafeCast Uint32 IDouble Source # 
SafeCast Uint32 IFloat Source # 
SafeCast Uint16 Sint64 Source # 
SafeCast Uint16 Sint32 Source # 
SafeCast Uint16 Uint64 Source # 
SafeCast Uint16 Uint32 Source # 
SafeCast Uint16 Uint16 Source # 
SafeCast Uint16 IDouble Source # 
SafeCast Uint16 IFloat Source # 
SafeCast Uint8 Sint64 Source # 
SafeCast Uint8 Sint32 Source # 
SafeCast Uint8 Sint16 Source # 
SafeCast Uint8 Uint64 Source # 
SafeCast Uint8 Uint32 Source # 
SafeCast Uint8 Uint16 Source # 
SafeCast Uint8 Uint8 Source # 

Methods

safeCast :: Uint8 -> Uint8 Source #

SafeCast Uint8 IDouble Source # 
SafeCast Uint8 IFloat Source # 
SafeCast IBool IChar Source # 

Methods

safeCast :: IBool -> IChar Source #

SafeCast IBool Sint64 Source # 
SafeCast IBool Sint32 Source # 
SafeCast IBool Sint16 Source # 
SafeCast IBool Sint8 Source # 

Methods

safeCast :: IBool -> Sint8 Source #

SafeCast IBool Uint64 Source # 
SafeCast IBool Uint32 Source # 
SafeCast IBool Uint16 Source # 
SafeCast IBool Uint8 Source # 

Methods

safeCast :: IBool -> Uint8 Source #

SafeCast IBool IBool Source # 

Methods

safeCast :: IBool -> IBool Source #

SafeCast IBool IDouble Source # 
SafeCast IBool IFloat Source # 
SafeCast IDouble IDouble Source # 
SafeCast IFloat IDouble Source # 
SafeCast IFloat IFloat Source # 
(ANat n, IvoryIntegral to, Default to) => SafeCast (Ix n) to Source # 

Methods

safeCast :: Ix n -> to Source #

class (IvoryExpr from, IvoryExpr to, Default to) => RuntimeCast from to Source #

Casts requiring runtime checks.

Minimal complete definition

inBounds

Instances

(Bounded from, Bounded to, IvoryOrd from, IvoryOrd to, IvoryExpr from, IvoryExpr to, Default from, Default to, SafeCast to from) => RuntimeCast from to Source # 

Methods

inBounds :: to -> from -> IBool

(Default to, Bounded to, IvoryIntegral to, SafeCast to IDouble) => RuntimeCast IDouble to Source # 

Methods

inBounds :: to -> IDouble -> IBool

(Default to, Bounded to, IvoryIntegral to, SafeCast to IFloat) => RuntimeCast IFloat to Source #

Casting from a floating to a Integral type always results in truncation.

Methods

inBounds :: to -> IFloat -> IBool

class Default a Source #

Default values for expression types.

Minimal complete definition

defaultVal

class (IvoryExpr from, IvoryExpr to) => SignCast from to where Source #

SignCast takes a unsigned number into its signed form iff safe, otherwise 0, and same with signed into unsigned

Minimal complete definition

signCast

Methods

signCast :: from -> to Source #