foundation-0.0.3: Alternative prelude with batteries and no dependencies

License | BSD-style
Maintainer | Haskell Foundation
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Foundation.Class.Storable

Description

https://github.com/haskell-foundation/issues/111

Synopsis

- class Storable a where
- class Storable a => StorableFixed a where
- data Ptr a :: * -> *
- plusPtr :: StorableFixed a => Ptr a -> Size a -> Ptr a
- castPtr :: Ptr a -> Ptr b
- peekOff :: StorableFixed a => Ptr a -> Offset a -> IO a
- pokeOff :: StorableFixed a => Ptr a -> Offset a -> a -> IO ()

# Documentation

class Storable a where #

Storable type of self determined size.

Minimal complete definition

peek, poke

Methods

peek :: Ptr a -> IO a #

poke :: Ptr a -> a -> IO () #

Instances

Storable Char # |
Methods peek :: Ptr Char -> IO Char # poke :: Ptr Char -> Char -> IO () #
Storable Double # |
Methods peek :: Ptr Double -> IO Double # poke :: Ptr Double -> Double -> IO () #
Storable Float # |
Methods peek :: Ptr Float -> IO Float # poke :: Ptr Float -> Float -> IO () #
Storable Int8 # |
Methods peek :: Ptr Int8 -> IO Int8 # poke :: Ptr Int8 -> Int8 -> IO () #
Storable Int16 # |
Methods peek :: Ptr Int16 -> IO Int16 # poke :: Ptr Int16 -> Int16 -> IO () #
Storable Int32 # |
Methods peek :: Ptr Int32 -> IO Int32 # poke :: Ptr Int32 -> Int32 -> IO () #
Storable Int64 # |
Methods peek :: Ptr Int64 -> IO Int64 # poke :: Ptr Int64 -> Int64 -> IO () #
Storable Word8 # |
Methods peek :: Ptr Word8 -> IO Word8 # poke :: Ptr Word8 -> Word8 -> IO () #
Storable Word16 # |
Methods peek :: Ptr Word16 -> IO Word16 # poke :: Ptr Word16 -> Word16 -> IO () #
Storable Word32 # |
Methods peek :: Ptr Word32 -> IO Word32 # poke :: Ptr Word32 -> Word32 -> IO () #
Storable Word64 # |
Methods peek :: Ptr Word64 -> IO Word64 # poke :: Ptr Word64 -> Word64 -> IO () #

class Storable a => StorableFixed a where #

Extending the Storable type class to the types that can be sequenced in a structure.

Minimal complete definition

size, alignment

Methods

size :: proxy a -> Size Word8 #

alignment :: proxy a -> Size Word8 #

Instances

StorableFixed Char # |
Methods size :: proxy Char -> Size Word8 # alignment :: proxy Char -> Size Word8 #
StorableFixed Double # |
Methods size :: proxy Double -> Size Word8 # alignment :: proxy Double -> Size Word8 #
StorableFixed Float # |
Methods size :: proxy Float -> Size Word8 # alignment :: proxy Float -> Size Word8 #
StorableFixed Int8 # |
Methods size :: proxy Int8 -> Size Word8 # alignment :: proxy Int8 -> Size Word8 #
StorableFixed Int16 # |
Methods size :: proxy Int16 -> Size Word8 # alignment :: proxy Int16 -> Size Word8 #
StorableFixed Int32 # |
Methods size :: proxy Int32 -> Size Word8 # alignment :: proxy Int32 -> Size Word8 #
StorableFixed Int64 # |
Methods size :: proxy Int64 -> Size Word8 # alignment :: proxy Int64 -> Size Word8 #
StorableFixed Word8 # |
Methods size :: proxy Word8 -> Size Word8 # alignment :: proxy Word8 -> Size Word8 #
StorableFixed Word16 # |
Methods size :: proxy Word16 -> Size Word8 # alignment :: proxy Word16 -> Size Word8 #
StorableFixed Word32 # |
Methods size :: proxy Word32 -> Size Word8 # alignment :: proxy Word32 -> Size Word8 #
StorableFixed Word64 # |
Methods size :: proxy Word64 -> Size Word8 # alignment :: proxy Word64 -> Size Word8 #

data Ptr a :: * -> * #

A value of type ``Ptr` a` represents a pointer to an object, or an array of objects, which may be marshalled to or from Haskell values of type `a`.

The type `a` will often be an instance of class `Storable` which provides the marshalling operations. However this is not essential, and you can provide your own operations to access the pointer. For example you might write small foreign functions to get or set the fields of a C `struct`.

Instances

Eq (Ptr a) |
Methods (==) :: Ptr a -> Ptr a -> Bool # (/=) :: Ptr a -> Ptr a -> Bool #
Data a => Data (Ptr a) |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ptr a -> c (Ptr a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Ptr a) # toConstr :: Ptr a -> Constr # dataTypeOf :: Ptr a -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Ptr a)) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ptr a)) # gmapT :: (forall b. Data b => b -> b) -> Ptr a -> Ptr a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ptr a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ptr a -> r # gmapQ :: (forall d. Data d => d -> u) -> Ptr a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Ptr a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ptr a -> m (Ptr a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ptr a -> m (Ptr a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ptr a -> m (Ptr a) #
Functor (URec (Ptr ())) |
Methods fmap :: (a -> b) -> URec (Ptr ()) a -> URec (Ptr ()) b # (<$) :: a -> URec (Ptr ()) b -> URec (Ptr ()) a #
Ord (Ptr a) |
Methods compare :: Ptr a -> Ptr a -> Ordering # (<) :: Ptr a -> Ptr a -> Bool # (<=) :: Ptr a -> Ptr a -> Bool # (>) :: Ptr a -> Ptr a -> Bool # (>=) :: Ptr a -> Ptr a -> Bool # max :: Ptr a -> Ptr a -> Ptr a # min :: Ptr a -> Ptr a -> Ptr a #
Show (Ptr a) |
Methods showsPrec :: Int -> Ptr a -> ShowS # show :: Ptr a -> String # showList :: [Ptr a] -> ShowS #
Foldable (URec (Ptr ())) |
Methods fold :: Monoid m => URec (Ptr ()) m -> m # foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m # foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # toList :: URec (Ptr ()) a -> [a] # null :: URec (Ptr ()) a -> Bool # length :: URec (Ptr ()) a -> Int # elem :: Eq a => a -> URec (Ptr ()) a -> Bool # maximum :: Ord a => URec (Ptr ()) a -> a # minimum :: Ord a => URec (Ptr ()) a -> a # sum :: Num a => URec (Ptr ()) a -> a # product :: Num a => URec (Ptr ()) a -> a #
Generic1 (URec (Ptr ())) |
Associated Types type Rep1 (URec (Ptr ()) :: * -> *) :: * -> * # Methods from1 :: URec (Ptr ()) a -> Rep1 (URec (Ptr ())) a # to1 :: Rep1 (URec (Ptr ())) a -> URec (Ptr ()) a #
Eq (URec (Ptr ()) p) |
Methods (==) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (/=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #
Ord (URec (Ptr ()) p) |
Methods compare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering # (<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p # min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p #
Generic (URec (Ptr ()) p) |
Associated Types type Rep (URec (Ptr ()) p) :: * -> * # Methods from :: URec (Ptr ()) p -> Rep (URec (Ptr ()) p) x # to :: Rep (URec (Ptr ()) p) x -> URec (Ptr ()) p #
type Rep1 (URec (Ptr ())) |
type Rep1 (URec (Ptr ())) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UAddr" PrefixI True) (S1 (MetaSel (Just Symbol "uAddr#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UAddr))
data URec (Ptr ()) | Used for marking occurrences of `Addr#`
data URec (Ptr ()) = UAddr { uAddr# :: Addr# }
type Rep (URec (Ptr ()) p) |
type Rep (URec (Ptr ()) p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UAddr" PrefixI True) (S1 (MetaSel (Just Symbol "uAddr#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UAddr))

plusPtr :: StorableFixed a => Ptr a -> Size a -> Ptr a #

castPtr :: Ptr a -> Ptr b #

The `castPtr` function casts a pointer from one type to another.

peekOff :: StorableFixed a => Ptr a -> Offset a -> IO a #

like `peek` but at a given offset.

pokeOff :: StorableFixed a => Ptr a -> Offset a -> a -> IO () #

like `poke` but at a given offset.