ivory-0.1.0.3: 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

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.

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

Statically safe casts.

Minimal complete definition

Nothing

Methods

safeCast :: from -> to Source

Instances

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 
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 
SafeCast Uint8 IDouble Source 
SafeCast Uint8 IFloat Source 
SafeCast IChar IChar Source 
SafeCast IBool Sint64 Source 
SafeCast IBool Sint32 Source 
SafeCast IBool Sint16 Source 
SafeCast IBool Sint8 Source 
SafeCast IBool Uint64 Source 
SafeCast IBool Uint32 Source 
SafeCast IBool Uint16 Source 
SafeCast IBool Uint8 Source 
SafeCast IBool IChar Source 
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 

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 
(Default to, Bounded to, IvoryIntegral to, SafeCast to IDouble) => RuntimeCast IDouble to Source 
(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.

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

Methods

signCast :: from -> to Source