-- |
-- Module      : Foundation.Class.Storable
-- License     : BSD-style
-- Maintainer  : Haskell Foundation
-- Stability   : experimental
-- Portability : portable
--
-- <https://github.com/haskell-foundation/issues/111>
--
--

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE CPP #-}

module Foundation.Class.Storable
    ( Storable(..)
    , StorableFixed(..)

      -- * Ptr
    , Ptr, plusPtr, castPtr
      -- * offset based helper
    , peekOff, pokeOff
      -- * Collection
    , peekArray
    , peekArrayEndedBy
    , pokeArray
    , pokeArrayEndedBy
    ) where

#include "MachDeps.h"

import Foreign.Ptr (castPtr)
import qualified Foreign.Ptr
import qualified Foreign.Storable (peek, poke)

import Basement.Compat.Base
import Basement.Compat.C.Types (CChar, CUChar)
import Basement.Types.OffsetSize
import Basement.Types.Word128 (Word128(..))
import Basement.Types.Word256 (Word256(..))
import Foundation.Collection
import Foundation.Collection.Buildable (builderLift)
import Basement.PrimType
import Basement.Endianness
import Foundation.Numerical

-- | Storable type of self determined size.
--
class Storable a where
    peek :: Ptr a -> IO a
    poke :: Ptr a -> a -> IO ()

-- | Extending the Storable type class to the types that can be sequenced
-- in a structure.
--
class Storable a => StorableFixed a where
    size :: proxy a -> CountOf Word8
    alignment :: proxy a -> CountOf Word8

plusPtr :: StorableFixed a => Ptr a -> CountOf a -> Ptr a
plusPtr :: forall a. StorableFixed a => Ptr a -> CountOf a -> Ptr a
plusPtr Ptr a
ptr (CountOf Int
num) = Ptr a
ptr Ptr a -> Int -> Ptr a
forall a b. Ptr a -> Int -> Ptr b
`Foreign.Ptr.plusPtr` (Int
num Int -> Int -> Int
forall a. Multiplicative a => a -> a -> a
* (Ptr a -> CountOf Word8
forall a (proxy :: * -> *).
StorableFixed a =>
proxy a -> CountOf Word8
forall (proxy :: * -> *). proxy a -> CountOf Word8
size Ptr a
ptr CountOf Word8 -> CountOf Word8 -> Int
forall {ty} {ty}. CountOf ty -> CountOf ty -> Int
`align` Ptr a -> CountOf Word8
forall a (proxy :: * -> *).
StorableFixed a =>
proxy a -> CountOf Word8
forall (proxy :: * -> *). proxy a -> CountOf Word8
alignment Ptr a
ptr))
  where
    align :: CountOf ty -> CountOf ty -> Int
align (CountOf Int
sz) (CountOf Int
a) = Int
sz Int -> Int -> Int
forall a. Additive a => a -> a -> a
+ (Int
sz Int -> Int -> Int
forall a. IDivisible a => a -> a -> a
`mod` Int
a)

-- | like `peek` but at a given offset.
peekOff :: StorableFixed a => Ptr a -> Offset a -> IO a
peekOff :: forall a. StorableFixed a => Ptr a -> Offset a -> IO a
peekOff Ptr a
ptr Offset a
off = Ptr a -> IO a
forall a. Storable a => Ptr a -> IO a
peek (Ptr a
ptr Ptr a -> CountOf a -> Ptr a
forall a. StorableFixed a => Ptr a -> CountOf a -> Ptr a
`plusPtr` Offset a -> CountOf a
forall a. Offset a -> CountOf a
offsetAsSize Offset a
off)

-- | like `poke` but at a given offset.
pokeOff :: StorableFixed a => Ptr a -> Offset a -> a -> IO ()
pokeOff :: forall a. StorableFixed a => Ptr a -> Offset a -> a -> IO ()
pokeOff Ptr a
ptr Offset a
off = Ptr a -> a -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr a
ptr Ptr a -> CountOf a -> Ptr a
forall a. StorableFixed a => Ptr a -> CountOf a -> Ptr a
`plusPtr` Offset a -> CountOf a
forall a. Offset a -> CountOf a
offsetAsSize Offset a
off)

peekArray :: (Buildable col, StorableFixed (Element col))
          => CountOf (Element col) -> Ptr (Element col) -> IO col
peekArray :: forall col.
(Buildable col, StorableFixed (Element col)) =>
CountOf (Element col) -> Ptr (Element col) -> IO col
peekArray (CountOf Int
s) Ptr (Element col)
p = Int -> Builder col (Mutable col) (Step col) IO () () -> IO col
forall c (prim :: * -> *).
(Buildable c, PrimMonad prim) =>
Int -> Builder c (Mutable c) (Step c) prim () () -> prim c
build_ Int
64 (Builder col (Mutable col) (Step col) IO () () -> IO col)
-> (Ptr (Element col)
    -> Builder col (Mutable col) (Step col) IO () ())
-> Ptr (Element col)
-> IO col
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Int
-> Ptr (Element col)
-> Builder col (Mutable col) (Step col) IO () ()
builder Int
0 (Ptr (Element col) -> IO col) -> Ptr (Element col) -> IO col
forall a b. (a -> b) -> a -> b
$ Ptr (Element col)
p
  where
    builder :: Int
-> Ptr (Element col)
-> Builder col (Mutable col) (Step col) IO () ()
builder Int
off Ptr (Element col)
ptr
      | Int
off Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
s = () -> Builder col (Mutable col) (Step col) IO () ()
forall a. a -> Builder col (Mutable col) (Step col) IO () a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
      | Bool
otherwise = do
          Element col
v <- IO (Element col)
-> Builder col (Mutable col) (Step col) IO () (Element col)
forall c (prim :: * -> *) a err.
(Buildable c, PrimMonad prim) =>
prim a -> Builder c (Mutable c) (Step c) prim err a
builderLift (Ptr (Element col) -> Offset (Element col) -> IO (Element col)
forall a. StorableFixed a => Ptr a -> Offset a -> IO a
peekOff Ptr (Element col)
ptr (Int -> Offset (Element col)
forall ty. Int -> Offset ty
Offset Int
off))
          Element col -> Builder col (Mutable col) (Step col) IO () ()
forall col (prim :: * -> *) err.
(Buildable col, PrimMonad prim) =>
Element col -> Builder col (Mutable col) (Step col) prim err ()
forall (prim :: * -> *) err.
PrimMonad prim =>
Element col -> Builder col (Mutable col) (Step col) prim err ()
append Element col
v
          Int
-> Ptr (Element col)
-> Builder col (Mutable col) (Step col) IO () ()
builder (Int
off Int -> Int -> Int
forall a. Additive a => a -> a -> a
+ Int
1) Ptr (Element col)
ptr

peekArrayEndedBy :: (Buildable col, StorableFixed (Element col), Eq (Element col), Show (Element col))
                 => Element col -> Ptr (Element col) -> IO col
peekArrayEndedBy :: forall col.
(Buildable col, StorableFixed (Element col), Eq (Element col),
 Show (Element col)) =>
Element col -> Ptr (Element col) -> IO col
peekArrayEndedBy Element col
term Ptr (Element col)
p = Int -> Builder col (Mutable col) (Step col) IO () () -> IO col
forall c (prim :: * -> *).
(Buildable c, PrimMonad prim) =>
Int -> Builder c (Mutable c) (Step c) prim () () -> prim c
build_ Int
64 (Builder col (Mutable col) (Step col) IO () () -> IO col)
-> (Ptr (Element col)
    -> Builder col (Mutable col) (Step col) IO () ())
-> Ptr (Element col)
-> IO col
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Offset (Element col)
-> Ptr (Element col)
-> Builder col (Mutable col) (Step col) IO () ()
builder Offset (Element col)
0 (Ptr (Element col) -> IO col) -> Ptr (Element col) -> IO col
forall a b. (a -> b) -> a -> b
$ Ptr (Element col)
p
  where
    builder :: Offset (Element col)
-> Ptr (Element col)
-> Builder col (Mutable col) (Step col) IO () ()
builder Offset (Element col)
off Ptr (Element col)
ptr = do
      Element col
v <- IO (Element col)
-> Builder col (Mutable col) (Step col) IO () (Element col)
forall c (prim :: * -> *) a err.
(Buildable c, PrimMonad prim) =>
prim a -> Builder c (Mutable c) (Step c) prim err a
builderLift (IO (Element col)
 -> Builder col (Mutable col) (Step col) IO () (Element col))
-> IO (Element col)
-> Builder col (Mutable col) (Step col) IO () (Element col)
forall a b. (a -> b) -> a -> b
$ Ptr (Element col) -> Offset (Element col) -> IO (Element col)
forall a. StorableFixed a => Ptr a -> Offset a -> IO a
peekOff Ptr (Element col)
ptr Offset (Element col)
off
      if Element col
term Element col -> Element col -> Bool
forall a. Eq a => a -> a -> Bool
== Element col
v
        then () -> Builder col (Mutable col) (Step col) IO () ()
forall a. a -> Builder col (Mutable col) (Step col) IO () a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        else Element col -> Builder col (Mutable col) (Step col) IO () ()
forall col (prim :: * -> *) err.
(Buildable col, PrimMonad prim) =>
Element col -> Builder col (Mutable col) (Step col) prim err ()
forall (prim :: * -> *) err.
PrimMonad prim =>
Element col -> Builder col (Mutable col) (Step col) prim err ()
append Element col
v Builder col (Mutable col) (Step col) IO () ()
-> Builder col (Mutable col) (Step col) IO () ()
-> Builder col (Mutable col) (Step col) IO () ()
forall a b.
Builder col (Mutable col) (Step col) IO () a
-> Builder col (Mutable col) (Step col) IO () b
-> Builder col (Mutable col) (Step col) IO () b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Offset (Element col)
-> Ptr (Element col)
-> Builder col (Mutable col) (Step col) IO () ()
builder (Offset (Element col)
off Offset (Element col)
-> Offset (Element col) -> Offset (Element col)
forall a. Additive a => a -> a -> a
+ (Int -> Offset (Element col)
forall ty. Int -> Offset ty
Offset Int
1)) Ptr (Element col)
ptr

pokeArray :: (Sequential col, StorableFixed (Element col))
          => Ptr (Element col) -> col -> IO ()
pokeArray :: forall col.
(Sequential col, StorableFixed (Element col)) =>
Ptr (Element col) -> col -> IO ()
pokeArray Ptr (Element col)
ptr col
arr =
    [(Int, Element col)] -> ((Int, Element col) -> IO ()) -> IO ()
forall (col :: * -> *) (m :: * -> *) a b.
(Mappable col, Applicative m, Monad m) =>
col a -> (a -> m b) -> m ()
forM_ ([Int] -> col -> [(Int, Element col)]
forall col.
(Sequential col, Collection col) =>
[Int] -> col -> [(Int, Element col)]
z [Int
0..] col
arr) (((Int, Element col) -> IO ()) -> IO ())
-> ((Int, Element col) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(Int
i, Element col
e) ->
        Ptr (Element col) -> Offset (Element col) -> Element col -> IO ()
forall a. StorableFixed a => Ptr a -> Offset a -> a -> IO ()
pokeOff Ptr (Element col)
ptr (Int -> Offset (Element col)
forall ty. Int -> Offset ty
Offset Int
i) Element col
e
  where
    z :: (Sequential col, Collection col) => [Int] -> col -> [(Int, Element col)]
    z :: forall col.
(Sequential col, Collection col) =>
[Int] -> col -> [(Int, Element col)]
z = [Int] -> col -> [(Int, Element col)]
forall col a b.
(BoxedZippable col, Sequential a, Sequential b,
 Element col ~ (Element a, Element b)) =>
a -> b -> col
forall a b.
(Sequential a, Sequential b,
 Element [(Int, Element col)] ~ (Element a, Element b)) =>
a -> b -> [(Int, Element col)]
zip

pokeArrayEndedBy :: (Sequential col, StorableFixed (Element col))
                 => Element col -> Ptr (Element col) -> col -> IO ()
pokeArrayEndedBy :: forall col.
(Sequential col, StorableFixed (Element col)) =>
Element col -> Ptr (Element col) -> col -> IO ()
pokeArrayEndedBy Element col
term Ptr (Element col)
ptr col
col = do
    Ptr (Element col) -> col -> IO ()
forall col.
(Sequential col, StorableFixed (Element col)) =>
Ptr (Element col) -> col -> IO ()
pokeArray Ptr (Element col)
ptr col
col
    Ptr (Element col) -> Offset (Element col) -> Element col -> IO ()
forall a. StorableFixed a => Ptr a -> Offset a -> a -> IO ()
pokeOff Ptr (Element col)
ptr (CountOf (Element col) -> Offset (Element col)
forall a. CountOf a -> Offset a
sizeAsOffset (CountOf (Element col) -> Offset (Element col))
-> CountOf (Element col) -> Offset (Element col)
forall a b. (a -> b) -> a -> b
$ col -> CountOf (Element col)
forall c. Collection c => c -> CountOf (Element c)
length col
col) Element col
term

instance Storable CChar where
    peek :: Ptr CChar -> IO CChar
peek (Ptr Addr#
addr) = Addr# -> Offset CChar -> IO CChar
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset CChar -> prim CChar
primAddrRead Addr#
addr (Int -> Offset CChar
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr CChar -> CChar -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset CChar -> CChar -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset CChar -> CChar -> prim ()
primAddrWrite Addr#
addr (Int -> Offset CChar
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable CUChar where
    peek :: Ptr CUChar -> IO CUChar
peek (Ptr Addr#
addr) = Addr# -> Offset CUChar -> IO CUChar
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset CUChar -> prim CUChar
primAddrRead Addr#
addr (Int -> Offset CUChar
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr CUChar -> CUChar -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset CUChar -> CUChar -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset CUChar -> CUChar -> prim ()
primAddrWrite Addr#
addr (Int -> Offset CUChar
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Char where
    peek :: Ptr Char -> IO Char
peek (Ptr Addr#
addr) = Addr# -> Offset Char -> IO Char
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Char -> prim Char
primAddrRead Addr#
addr (Int -> Offset Char
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Char -> Char -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Char -> Char -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Char -> Char -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Char
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Double where
    peek :: Ptr Double -> IO Double
peek (Ptr Addr#
addr) = Addr# -> Offset Double -> IO Double
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Double -> prim Double
primAddrRead Addr#
addr (Int -> Offset Double
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Double -> Double -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Double -> Double -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Double -> Double -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Double
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Float where
    peek :: Ptr Float -> IO Float
peek (Ptr Addr#
addr) = Addr# -> Offset Float -> IO Float
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Float -> prim Float
primAddrRead Addr#
addr (Int -> Offset Float
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Float -> Float -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Float -> Float -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Float -> Float -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Float
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Int8 where
    peek :: Ptr Int8 -> IO Int8
peek (Ptr Addr#
addr) = Addr# -> Offset Int8 -> IO Int8
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int8 -> prim Int8
primAddrRead Addr#
addr (Int -> Offset Int8
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Int8 -> Int8 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Int8 -> Int8 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int8 -> Int8 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Int8
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Int16 where
    peek :: Ptr Int16 -> IO Int16
peek (Ptr Addr#
addr) = Addr# -> Offset Int16 -> IO Int16
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int16 -> prim Int16
primAddrRead Addr#
addr (Int -> Offset Int16
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Int16 -> Int16 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Int16 -> Int16 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int16 -> Int16 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Int16
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Int32 where
    peek :: Ptr Int32 -> IO Int32
peek (Ptr Addr#
addr) = Addr# -> Offset Int32 -> IO Int32
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int32 -> prim Int32
primAddrRead Addr#
addr (Int -> Offset Int32
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Int32 -> Int32 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Int32 -> Int32 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int32 -> Int32 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Int32
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Int64 where
    peek :: Ptr Int64 -> IO Int64
peek (Ptr Addr#
addr) = Addr# -> Offset Int64 -> IO Int64
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int64 -> prim Int64
primAddrRead Addr#
addr (Int -> Offset Int64
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Int64 -> Int64 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Int64 -> Int64 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Int64 -> Int64 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Int64
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Word8 where
    peek :: Ptr Word8 -> IO Word8
peek (Ptr Addr#
addr) = Addr# -> Offset Word8 -> IO Word8
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word8 -> prim Word8
primAddrRead Addr#
addr (Int -> Offset Word8
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Word8 -> Word8 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word8 -> Word8 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word8 -> Word8 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word8
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable Word16 where
    peek :: Ptr Word16 -> IO Word16
peek (Ptr Addr#
addr) = Addr# -> Offset Word16 -> IO Word16
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word16 -> prim Word16
primAddrRead Addr#
addr (Int -> Offset Word16
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Word16 -> Word16 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word16 -> Word16 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word16 -> Word16 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word16
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable (BE Word16) where
    peek :: Ptr (BE Word16) -> IO (BE Word16)
peek (Ptr Addr#
addr) = Word16 -> BE Word16
forall a. a -> BE a
BE (Word16 -> BE Word16) -> IO Word16 -> IO (BE Word16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word16 -> IO Word16
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word16 -> prim Word16
primAddrRead Addr#
addr (Int -> Offset Word16
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (BE Word16) -> BE Word16 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word16 -> Word16 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word16 -> Word16 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word16
forall ty. Int -> Offset ty
Offset Int
0) (Word16 -> IO ()) -> (BE Word16 -> Word16) -> BE Word16 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. BE Word16 -> Word16
forall a. BE a -> a
unBE
instance Storable (LE Word16) where
    peek :: Ptr (LE Word16) -> IO (LE Word16)
peek (Ptr Addr#
addr) = Word16 -> LE Word16
forall a. a -> LE a
LE (Word16 -> LE Word16) -> IO Word16 -> IO (LE Word16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word16 -> IO Word16
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word16 -> prim Word16
primAddrRead Addr#
addr (Int -> Offset Word16
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (LE Word16) -> LE Word16 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word16 -> Word16 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word16 -> Word16 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word16
forall ty. Int -> Offset ty
Offset Int
0) (Word16 -> IO ()) -> (LE Word16 -> Word16) -> LE Word16 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. LE Word16 -> Word16
forall a. LE a -> a
unLE
instance Storable Word32 where
    peek :: Ptr Word32 -> IO Word32
peek (Ptr Addr#
addr) = Addr# -> Offset Word32 -> IO Word32
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word32 -> prim Word32
primAddrRead Addr#
addr (Int -> Offset Word32
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Word32 -> Word32 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word32 -> Word32 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word32 -> Word32 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word32
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable (BE Word32) where
    peek :: Ptr (BE Word32) -> IO (BE Word32)
peek (Ptr Addr#
addr) = Word32 -> BE Word32
forall a. a -> BE a
BE (Word32 -> BE Word32) -> IO Word32 -> IO (BE Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word32 -> IO Word32
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word32 -> prim Word32
primAddrRead Addr#
addr (Int -> Offset Word32
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (BE Word32) -> BE Word32 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word32 -> Word32 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word32 -> Word32 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word32
forall ty. Int -> Offset ty
Offset Int
0) (Word32 -> IO ()) -> (BE Word32 -> Word32) -> BE Word32 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. BE Word32 -> Word32
forall a. BE a -> a
unBE
instance Storable (LE Word32) where
    peek :: Ptr (LE Word32) -> IO (LE Word32)
peek (Ptr Addr#
addr) = Word32 -> LE Word32
forall a. a -> LE a
LE (Word32 -> LE Word32) -> IO Word32 -> IO (LE Word32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word32 -> IO Word32
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word32 -> prim Word32
primAddrRead Addr#
addr (Int -> Offset Word32
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (LE Word32) -> LE Word32 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word32 -> Word32 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word32 -> Word32 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word32
forall ty. Int -> Offset ty
Offset Int
0) (Word32 -> IO ()) -> (LE Word32 -> Word32) -> LE Word32 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. LE Word32 -> Word32
forall a. LE a -> a
unLE
instance Storable Word64 where
    peek :: Ptr Word64 -> IO Word64
peek (Ptr Addr#
addr) = Addr# -> Offset Word64 -> IO Word64
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word64 -> prim Word64
primAddrRead Addr#
addr (Int -> Offset Word64
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Word64 -> Word64 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word64 -> Word64 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word64 -> Word64 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word64
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable (BE Word64) where
    peek :: Ptr (BE Word64) -> IO (BE Word64)
peek (Ptr Addr#
addr) = Word64 -> BE Word64
forall a. a -> BE a
BE (Word64 -> BE Word64) -> IO Word64 -> IO (BE Word64)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word64 -> IO Word64
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word64 -> prim Word64
primAddrRead Addr#
addr (Int -> Offset Word64
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (BE Word64) -> BE Word64 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word64 -> Word64 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word64 -> Word64 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word64
forall ty. Int -> Offset ty
Offset Int
0) (Word64 -> IO ()) -> (BE Word64 -> Word64) -> BE Word64 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. BE Word64 -> Word64
forall a. BE a -> a
unBE
instance Storable (LE Word64) where
    peek :: Ptr (LE Word64) -> IO (LE Word64)
peek (Ptr Addr#
addr) = Word64 -> LE Word64
forall a. a -> LE a
LE (Word64 -> LE Word64) -> IO Word64 -> IO (LE Word64)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word64 -> IO Word64
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word64 -> prim Word64
primAddrRead Addr#
addr (Int -> Offset Word64
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (LE Word64) -> LE Word64 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word64 -> Word64 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word64 -> Word64 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word64
forall ty. Int -> Offset ty
Offset Int
0) (Word64 -> IO ()) -> (LE Word64 -> Word64) -> LE Word64 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. LE Word64 -> Word64
forall a. LE a -> a
unLE
instance Storable Word128 where
    peek :: Ptr Word128 -> IO Word128
peek (Ptr Addr#
addr) = Addr# -> Offset Word128 -> IO Word128
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word128 -> prim Word128
primAddrRead Addr#
addr (Int -> Offset Word128
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Word128 -> Word128 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word128 -> Word128 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word128 -> Word128 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word128
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable (BE Word128) where
    peek :: Ptr (BE Word128) -> IO (BE Word128)
peek (Ptr Addr#
addr) = Word128 -> BE Word128
forall a. a -> BE a
BE (Word128 -> BE Word128) -> IO Word128 -> IO (BE Word128)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word128 -> IO Word128
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word128 -> prim Word128
primAddrRead Addr#
addr (Int -> Offset Word128
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (BE Word128) -> BE Word128 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word128 -> Word128 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word128 -> Word128 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word128
forall ty. Int -> Offset ty
Offset Int
0) (Word128 -> IO ())
-> (BE Word128 -> Word128) -> BE Word128 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. BE Word128 -> Word128
forall a. BE a -> a
unBE
instance Storable (LE Word128) where
    peek :: Ptr (LE Word128) -> IO (LE Word128)
peek (Ptr Addr#
addr) = Word128 -> LE Word128
forall a. a -> LE a
LE (Word128 -> LE Word128) -> IO Word128 -> IO (LE Word128)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word128 -> IO Word128
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word128 -> prim Word128
primAddrRead Addr#
addr (Int -> Offset Word128
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (LE Word128) -> LE Word128 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word128 -> Word128 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word128 -> Word128 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word128
forall ty. Int -> Offset ty
Offset Int
0) (Word128 -> IO ())
-> (LE Word128 -> Word128) -> LE Word128 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. LE Word128 -> Word128
forall a. LE a -> a
unLE
instance Storable Word256 where
    peek :: Ptr Word256 -> IO Word256
peek (Ptr Addr#
addr) = Addr# -> Offset Word256 -> IO Word256
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word256 -> prim Word256
primAddrRead Addr#
addr (Int -> Offset Word256
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr Word256 -> Word256 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word256 -> Word256 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word256 -> Word256 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word256
forall ty. Int -> Offset ty
Offset Int
0)
instance Storable (BE Word256) where
    peek :: Ptr (BE Word256) -> IO (BE Word256)
peek (Ptr Addr#
addr) = Word256 -> BE Word256
forall a. a -> BE a
BE (Word256 -> BE Word256) -> IO Word256 -> IO (BE Word256)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word256 -> IO Word256
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word256 -> prim Word256
primAddrRead Addr#
addr (Int -> Offset Word256
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (BE Word256) -> BE Word256 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word256 -> Word256 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word256 -> Word256 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word256
forall ty. Int -> Offset ty
Offset Int
0) (Word256 -> IO ())
-> (BE Word256 -> Word256) -> BE Word256 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. BE Word256 -> Word256
forall a. BE a -> a
unBE
instance Storable (LE Word256) where
    peek :: Ptr (LE Word256) -> IO (LE Word256)
peek (Ptr Addr#
addr) = Word256 -> LE Word256
forall a. a -> LE a
LE (Word256 -> LE Word256) -> IO Word256 -> IO (LE Word256)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Addr# -> Offset Word256 -> IO Word256
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> prim ty
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word256 -> prim Word256
primAddrRead Addr#
addr (Int -> Offset Word256
forall ty. Int -> Offset ty
Offset Int
0)
    poke :: Ptr (LE Word256) -> LE Word256 -> IO ()
poke (Ptr Addr#
addr) = Addr# -> Offset Word256 -> Word256 -> IO ()
forall ty (prim :: * -> *).
(PrimType ty, PrimMonad prim) =>
Addr# -> Offset ty -> ty -> prim ()
forall (prim :: * -> *).
PrimMonad prim =>
Addr# -> Offset Word256 -> Word256 -> prim ()
primAddrWrite Addr#
addr (Int -> Offset Word256
forall ty. Int -> Offset ty
Offset Int
0) (Word256 -> IO ())
-> (LE Word256 -> Word256) -> LE Word256 -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. LE Word256 -> Word256
forall a. LE a -> a
unLE
instance Storable (Ptr a) where
    peek :: Ptr (Ptr a) -> IO (Ptr a)
peek = Ptr (Ptr a) -> IO (Ptr a)
forall a. Storable a => Ptr a -> IO a
Foreign.Storable.peek
    poke :: Ptr (Ptr a) -> Ptr a -> IO ()
poke = Ptr (Ptr a) -> Ptr a -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
Foreign.Storable.poke

instance StorableFixed CChar where
    size :: forall (proxy :: * -> *). proxy CChar -> CountOf Word8
size      = CountOf Word8 -> proxy CChar -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_CHAR
    alignment :: forall (proxy :: * -> *). proxy CChar -> CountOf Word8
alignment = CountOf Word8 -> proxy CChar -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_CHAR
instance StorableFixed CUChar where
    size :: forall (proxy :: * -> *). proxy CUChar -> CountOf Word8
size      = CountOf Word8 -> proxy CUChar -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD8
    alignment :: forall (proxy :: * -> *). proxy CUChar -> CountOf Word8
alignment = CountOf Word8 -> proxy CUChar -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD8
instance StorableFixed Char where
    size :: forall (proxy :: * -> *). proxy Char -> CountOf Word8
size      = CountOf Word8 -> proxy Char -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_HSCHAR
    alignment :: forall (proxy :: * -> *). proxy Char -> CountOf Word8
alignment = CountOf Word8 -> proxy Char -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_HSCHAR
instance StorableFixed Double where
    size :: forall (proxy :: * -> *). proxy Double -> CountOf Word8
size      = CountOf Word8 -> proxy Double -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_HSDOUBLE
    alignment :: forall (proxy :: * -> *). proxy Double -> CountOf Word8
alignment = CountOf Word8 -> proxy Double -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_HSDOUBLE
instance StorableFixed Float where
    size :: forall (proxy :: * -> *). proxy Float -> CountOf Word8
size      = CountOf Word8 -> proxy Float -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_HSFLOAT
    alignment :: forall (proxy :: * -> *). proxy Float -> CountOf Word8
alignment = CountOf Word8 -> proxy Float -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_HSFLOAT
instance StorableFixed Int8 where
    size :: forall (proxy :: * -> *). proxy Int8 -> CountOf Word8
size      = CountOf Word8 -> proxy Int8 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_INT8
    alignment :: forall (proxy :: * -> *). proxy Int8 -> CountOf Word8
alignment = CountOf Word8 -> proxy Int8 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_INT8
instance StorableFixed Int16 where
    size :: forall (proxy :: * -> *). proxy Int16 -> CountOf Word8
size      = CountOf Word8 -> proxy Int16 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_INT16
    alignment :: forall (proxy :: * -> *). proxy Int16 -> CountOf Word8
alignment = CountOf Word8 -> proxy Int16 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_INT16
instance StorableFixed Int32 where
    size :: forall (proxy :: * -> *). proxy Int32 -> CountOf Word8
size      = CountOf Word8 -> proxy Int32 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_INT32
    alignment :: forall (proxy :: * -> *). proxy Int32 -> CountOf Word8
alignment = CountOf Word8 -> proxy Int32 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_INT32
instance StorableFixed Int64 where
    size :: forall (proxy :: * -> *). proxy Int64 -> CountOf Word8
size      = CountOf Word8 -> proxy Int64 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_INT64
    alignment :: forall (proxy :: * -> *). proxy Int64 -> CountOf Word8
alignment = CountOf Word8 -> proxy Int64 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_INT64
instance StorableFixed Word8 where
    size :: forall (proxy :: * -> *). proxy Word8 -> CountOf Word8
size      = CountOf Word8 -> proxy Word8 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD8
    alignment :: forall (proxy :: * -> *). proxy Word8 -> CountOf Word8
alignment = CountOf Word8 -> proxy Word8 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD8
instance StorableFixed Word16 where
    size :: forall (proxy :: * -> *). proxy Word16 -> CountOf Word8
size      = CountOf Word8 -> proxy Word16 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD16
    alignment :: forall (proxy :: * -> *). proxy Word16 -> CountOf Word8
alignment = CountOf Word8 -> proxy Word16 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD16
instance StorableFixed (BE Word16) where
    size :: forall (proxy :: * -> *). proxy (BE Word16) -> CountOf Word8
size      = CountOf Word8 -> proxy (BE Word16) -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD16
    alignment :: forall (proxy :: * -> *). proxy (BE Word16) -> CountOf Word8
alignment = CountOf Word8 -> proxy (BE Word16) -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD16
instance StorableFixed (LE Word16) where
    size :: forall (proxy :: * -> *). proxy (LE Word16) -> CountOf Word8
size      = CountOf Word8 -> proxy (LE Word16) -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD16
    alignment :: forall (proxy :: * -> *). proxy (LE Word16) -> CountOf Word8
alignment = CountOf Word8 -> proxy (LE Word16) -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD16
instance StorableFixed Word32 where
    size :: forall (proxy :: * -> *). proxy Word32 -> CountOf Word8
size      = CountOf Word8 -> proxy Word32 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD32
    alignment :: forall (proxy :: * -> *). proxy Word32 -> CountOf Word8
alignment = CountOf Word8 -> proxy Word32 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD32
instance StorableFixed (BE Word32) where
    size :: forall (proxy :: * -> *). proxy (BE Word32) -> CountOf Word8
size      = CountOf Word8 -> proxy (BE Word32) -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD32
    alignment :: forall (proxy :: * -> *). proxy (BE Word32) -> CountOf Word8
alignment = CountOf Word8 -> proxy (BE Word32) -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD32
instance StorableFixed (LE Word32) where
    size :: forall (proxy :: * -> *). proxy (LE Word32) -> CountOf Word8
size      = CountOf Word8 -> proxy (LE Word32) -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD32
    alignment :: forall (proxy :: * -> *). proxy (LE Word32) -> CountOf Word8
alignment = CountOf Word8 -> proxy (LE Word32) -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD32
instance StorableFixed Word64 where
    size :: forall (proxy :: * -> *). proxy Word64 -> CountOf Word8
size      = CountOf Word8 -> proxy Word64 -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD64
    alignment :: forall (proxy :: * -> *). proxy Word64 -> CountOf Word8
alignment = CountOf Word8 -> proxy Word64 -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD64
instance StorableFixed (BE Word64) where
    size :: forall (proxy :: * -> *). proxy (BE Word64) -> CountOf Word8
size      = CountOf Word8 -> proxy (BE Word64) -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD64
    alignment :: forall (proxy :: * -> *). proxy (BE Word64) -> CountOf Word8
alignment = CountOf Word8 -> proxy (BE Word64) -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD64
instance StorableFixed (LE Word64) where
    size :: forall (proxy :: * -> *). proxy (LE Word64) -> CountOf Word8
size      = CountOf Word8 -> proxy (LE Word64) -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_WORD64
    alignment :: forall (proxy :: * -> *). proxy (LE Word64) -> CountOf Word8
alignment = CountOf Word8 -> proxy (LE Word64) -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_WORD64
instance StorableFixed Word128 where
    size :: forall (proxy :: * -> *). proxy Word128 -> CountOf Word8
size      = CountOf Word8 -> proxy Word128 -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
16
    alignment :: forall (proxy :: * -> *). proxy Word128 -> CountOf Word8
alignment = CountOf Word8 -> proxy Word128 -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
16
instance StorableFixed (BE Word128) where
    size :: forall (proxy :: * -> *). proxy (BE Word128) -> CountOf Word8
size      = CountOf Word8 -> proxy (BE Word128) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
16
    alignment :: forall (proxy :: * -> *). proxy (BE Word128) -> CountOf Word8
alignment = CountOf Word8 -> proxy (BE Word128) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
16
instance StorableFixed (LE Word128) where
    size :: forall (proxy :: * -> *). proxy (LE Word128) -> CountOf Word8
size      = CountOf Word8 -> proxy (LE Word128) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
16
    alignment :: forall (proxy :: * -> *). proxy (LE Word128) -> CountOf Word8
alignment = CountOf Word8 -> proxy (LE Word128) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
16
instance StorableFixed Word256 where
    size :: forall (proxy :: * -> *). proxy Word256 -> CountOf Word8
size      = CountOf Word8 -> proxy Word256 -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
32
    alignment :: forall (proxy :: * -> *). proxy Word256 -> CountOf Word8
alignment = CountOf Word8 -> proxy Word256 -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
32
instance StorableFixed (BE Word256) where
    size :: forall (proxy :: * -> *). proxy (BE Word256) -> CountOf Word8
size      = CountOf Word8 -> proxy (BE Word256) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
32
    alignment :: forall (proxy :: * -> *). proxy (BE Word256) -> CountOf Word8
alignment = CountOf Word8 -> proxy (BE Word256) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
32
instance StorableFixed (LE Word256) where
    size :: forall (proxy :: * -> *). proxy (LE Word256) -> CountOf Word8
size      = CountOf Word8 -> proxy (LE Word256) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
32
    alignment :: forall (proxy :: * -> *). proxy (LE Word256) -> CountOf Word8
alignment = CountOf Word8 -> proxy (LE Word256) -> CountOf Word8
forall a b. a -> b -> a
const CountOf Word8
32
instance StorableFixed (Ptr a) where
    size :: forall (proxy :: * -> *). proxy (Ptr a) -> CountOf Word8
size      = CountOf Word8 -> proxy (Ptr a) -> CountOf Word8
forall a b. a -> b -> a
const SIZEOF_HSPTR
    alignment :: forall (proxy :: * -> *). proxy (Ptr a) -> CountOf Word8
alignment = CountOf Word8 -> proxy (Ptr a) -> CountOf Word8
forall a b. a -> b -> a
const ALIGNMENT_HSPTR