-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fixed-size wrapper for StorableArrays, with its own Storable instance -- -- Uses type-level numeric literals to wrap StorableArray in a -- type that statically fixes its size. This allows the wrapper to have -- its own Storable instance, which allows easy integration with -- fixed-size native arrays. @package fixed-storable-array @version 0.2.0.0 -- | This module exposes FixedStorableArray, a simple wrapper around -- StorableArray that uses the DataKinds extension to get -- type-level numeric literals. These allow dimensions to be fully set by -- the type at compile time. FixedStorableArray provides a -- Storable instance that significantly eases writing FFI bindings -- to fixed-size native arrays. -- -- For example, FixedStorableArray (N 10) CInt has -- a Storable instance that is directly compatible with int -- foo[10] in native code. -- -- Multidimensional native arrays are also supported. -- FixedStorableArray (N 10, N 20, N 100) -- CUChar is compatible with unsigned char -- foo[10][20][100]. -- -- Other than the Storable instance, newFixedStorableArray, -- and newFixedStorableArray_, the only way to work with a -- FixedStorableArray is to use toStorableArray and operate -- on the underlying StorableArray. toStorableArray -- generates a StorableArray with the correct type and index -- values already in place. For instance, the result of -- toStorableArray on a FixedStorableArray (N -- 10, N 20, N 100) CUChar is a -- StorableArray (Int, Int, Int) CUChar with its bounds -- set to ((0,0,0),(9,19,99)). module Foreign.Marshal.FixedStorableArray -- | 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. To -- get most functionality, use toStorableArray. data FixedStorableArray dimensions e -- | Create a FixedStorableArray and populate it with copies of the -- element passed in. Dimensions will be determined from the return type. newFixedStorableArray :: (HasBounds d, Ix (Bound d), Storable e) => e -> IO (FixedStorableArray d e) -- | Create a 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. newFixedStorableArray_ :: (HasBounds d, Ix (Bound d), Storable e) => IO (FixedStorableArray d e) -- | Returns the backing StorableArray of this -- FixedStorableArray. The backing array is shared across all -- invocations of this. Modifications to it will be seen across all uses -- of this FixedStorableArray. toStorableArray :: FixedStorableArray dimensions e -> StorableArray (Bound dimensions) e -- | This is a simple proxy type for type-level naturals. All dimension -- types use this type to store the size along that dimension. data N (n :: Nat) N :: N -- | A conversion function for converting type-level naturals to -- value-level. This is being exposed to aid in the creation of -- additional HasBounds instances for those who might desire to do -- so. Haddock is currently eating the important qualification that the -- type variable n must have the kind Nat. fromNat :: SingI n => proxy n -> Int -- | This class connects dimension descriptions with StorableArray -- index types and values. class HasBounds d where type family Bound d :: * bounds :: HasBounds d => FixedStorableArray d e -> (Bound d, Bound d) instance Eq (N n) instance Ord (N n) instance Enum (N n) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f, SingI Nat g, SingI Nat h, SingI Nat i, SingI Nat j, SingI Nat k, SingI Nat l, SingI Nat m) => HasBounds (N a, N b, N c, N d, N e, N f, N g, N h, N i, N j, N k, N l, N m) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f, SingI Nat g, SingI Nat h, SingI Nat i, SingI Nat j, SingI Nat k, SingI Nat l) => HasBounds (N a, N b, N c, N d, N e, N f, N g, N h, N i, N j, N k, N l) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f, SingI Nat g, SingI Nat h, SingI Nat i, SingI Nat j, SingI Nat k) => HasBounds (N a, N b, N c, N d, N e, N f, N g, N h, N i, N j, N k) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f, SingI Nat g, SingI Nat h, SingI Nat i, SingI Nat j) => HasBounds (N a, N b, N c, N d, N e, N f, N g, N h, N i, N j) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f, SingI Nat g, SingI Nat h, SingI Nat i) => HasBounds (N a, N b, N c, N d, N e, N f, N g, N h, N i) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f, SingI Nat g, SingI Nat h) => HasBounds (N a, N b, N c, N d, N e, N f, N g, N h) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f, SingI Nat g) => HasBounds (N a, N b, N c, N d, N e, N f, N g) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e, SingI Nat f) => HasBounds (N a, N b, N c, N d, N e, N f) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d, SingI Nat e) => HasBounds (N a, N b, N c, N d, N e) instance (SingI Nat a, SingI Nat b, SingI Nat c, SingI Nat d) => HasBounds (N a, N b, N c, N d) instance (SingI Nat a, SingI Nat b, SingI Nat c) => HasBounds (N a, N b, N c) instance (SingI Nat a, SingI Nat b) => HasBounds (N a, N b) instance SingI Nat a => HasBounds (N a) instance (HasBounds d, Ix (Bound d), Storable e) => Storable (FixedStorableArray d e) instance SingI Nat n => Show (N n)