Deprecated - use storable-static-array instead.
This module defines
FixedStorableArray, a simple wrapper around
StorableArray with its dimensions encoded in the
FixedStorableArray provides a
Storable instance that uses
the type-level dimensions, and significantly eases writing FFI
bindings to fixed-size native arrays. For example,
FixedStorableArray 10 CInt
Storable instance that is
directly compatible with
int foo in native code.
Multidimensional native arrays are also
FixedStorableArray '(10,20,100) CUChar
unsigned char foo. Note the leading
the tuple containing the dimensions. It marks it as a
lifted tuple, necessary to store the dimensions.
To operate on the contents of a
toStorableArray returns a
the correct type and index values already in place. For example, the
toStorableArray on a
with its bounds
StorableArray (Int, Int, Int) CUChar
- data FixedStorableArray dimensions e
- newFixedStorableArray :: (HasBounds d, Ix (Bound d), Storable e) => e -> IO (FixedStorableArray d e)
- newFixedStorableArray_ :: (HasBounds d, Ix (Bound d), Storable e) => IO (FixedStorableArray d e)
- toStorableArray :: FixedStorableArray dimensions e -> StorableArray (Bound dimensions) e
- class HasBounds d where
- fromNat :: forall proxy n. SingI n => proxy n -> Int
A minimal wrapper for
StorableArray that encodes the full
dimensions of the array in the type. Intended for interfacing with
(possibly-)multidimensional arrays of fixed size in native code.
FixedStorableArray and populate it with copies of the
element passed in. Dimensions will be determined from the return
FixedStorableArray and don't populate it with anything
in particular. Contents may or may not be initialized to anything
at all. Dimensions will be determined from the return type.
This class connects dimension description types with
StorableArray index types and values. Instances are provided for
up to 13 dimensions. More can be added if there's any need.
A conversion function for converting type-level naturals to
value-level. This is being exposed to aid in the creation of
HasBounds instances for those who might desire to do
Haddock is currently eating the important qualification that the
n must have the kind
SingI instance is
automatically fulfilled for all types of kind
Nat. Its explicit
presence in the signature is an artifact of how GHC implements
dictionary passing and type erasure.