hdf5-1.8.15: Haskell interface to the HDF5 scientific data storage library.

Safe Haskell | None
Language | Haskell2010

Foreign.Ptr.Conventions

Contents

- Input pointers
- Output pointers
- Bidirectional pointers

Description

various common data-passing conventions

Synopsis

- class WrappedPtr (p :: Type -> Type) where
  - wrapPtr :: Ptr a -> p a
  - unwrapPtr :: p a -> Ptr a
  - nullWrappedPtr :: p a
  - castWrappedPtr :: p a -> p b
- newtype In a = In (Ptr a)
- newtype InArray a = InArray (Ptr a)
- withIn :: (Storable a, MonadBaseControl IO m) => a -> (In a -> m b) -> m b
- withInList :: (Storable a, MonadBaseControl IO m) => [a] -> (InArray a -> m b) -> m b
- withInVector :: (Storable a, MonadBaseControl IO m) => Vector a -> (InArray a -> m b) -> m b
- withInMVector :: (Storable a, MonadBaseControl IO m) => IOVector a -> (InArray a -> m b) -> m b
- newtype Out a = Out (Ptr a)
- newtype OutArray a = OutArray (Ptr a)
- withOut :: (Storable a, MonadBaseControl IO m, MonadIO m) => (Out a -> m b) -> m (a, b)
- withMaybeOut :: (Storable a, MonadBaseControl IO m, MonadIO m) => (Out a -> m Bool) -> m (Maybe a)
- withOut_ :: (Storable a, MonadBaseControl IO m, MonadIO m) => (Out a -> m b) -> m a
- withOutMVector :: (Storable a, MonadBaseControl IO m) => IOVector a -> (Int -> OutArray a -> m b) -> m b
- withOutVector :: (Storable a, MonadBaseControl IO m, MonadIO m) => Int -> (OutArray a -> m b) -> m (Vector a, b)
- withOutVector_ :: Storable a => Int -> (OutArray a -> IO b) -> IO (Vector a)
- withOutVector' :: (Storable a, Integral b) => Int -> (OutArray a -> IO b) -> IO (Vector a)
- withOutList :: (Storable a, MonadIO m) => Int -> (OutArray a -> m b) -> m ([a], b)
- withOutList_ :: (Storable a, MonadIO m) => Int -> (OutArray a -> m b) -> m [a]
- withOutList' :: (Storable a, MonadIO m) => Int -> (OutArray a -> m Int) -> m ([a], Int)
- withOutList0 :: (Storable a, Eq a, MonadIO m) => a -> Int -> (OutArray a -> m b) -> m ([a], b)
- withOutByteString :: (MonadBaseControl IO m, MonadIO m, Integral a, Integral b) => (OutArray CChar -> a -> m b) -> m ByteString
- withOutByteString' :: (MonadBaseControl IO m, MonadIO m, Integral a, Integral b) => (OutArray CChar -> a -> m b) -> m ByteString
- newtype InOut a = InOut (Ptr a)
- newtype InOutArray a = InOutArray (Ptr a)
- withInOut :: (Storable a, MonadBaseControl IO m, MonadIO m) => a -> (InOut a -> m b) -> m (a, b)
- withInOut_ :: (Storable a, MonadBaseControl IO m, MonadIO m) => a -> (InOut a -> m b) -> m a
- withInOutList :: (Storable a, MonadIO m) => Int -> [a] -> (InOutArray a -> m (Int, b)) -> m ([a], b)
- withInOutList_ :: (Storable a, MonadIO m) => Int -> [a] -> (InOutArray a -> m Int) -> m [a]

# Documentation

class WrappedPtr (p :: Type -> Type) where Source #

Minimal complete definition

wrapPtr, unwrapPtr

Methods

wrapPtr :: Ptr a -> p a Source #

unwrapPtr :: p a -> Ptr a Source #

nullWrappedPtr :: p a Source #

castWrappedPtr :: p a -> p b Source #

#### Instances

Instances details

WrappedPtr Ptr Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> Ptr a Source # unwrapPtr :: Ptr a -> Ptr a Source # nullWrappedPtr :: Ptr a Source # castWrappedPtr :: Ptr a -> Ptr b Source #
WrappedPtr In Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> In a Source # unwrapPtr :: In a -> Ptr a Source # nullWrappedPtr :: In a Source # castWrappedPtr :: In a -> In b Source #
WrappedPtr InArray Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> InArray a Source # unwrapPtr :: InArray a -> Ptr a Source # nullWrappedPtr :: InArray a Source # castWrappedPtr :: InArray a -> InArray b Source #
WrappedPtr InOut Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> InOut a Source # unwrapPtr :: InOut a -> Ptr a Source # nullWrappedPtr :: InOut a Source # castWrappedPtr :: InOut a -> InOut b Source #
WrappedPtr InOutArray Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> InOutArray a Source # unwrapPtr :: InOutArray a -> Ptr a Source # nullWrappedPtr :: InOutArray a Source # castWrappedPtr :: InOutArray a -> InOutArray b Source #
WrappedPtr Out Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> Out a Source # unwrapPtr :: Out a -> Ptr a Source # nullWrappedPtr :: Out a Source # castWrappedPtr :: Out a -> Out b Source #
WrappedPtr OutArray Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> OutArray a Source # unwrapPtr :: OutArray a -> Ptr a Source # nullWrappedPtr :: OutArray a Source # castWrappedPtr :: OutArray a -> OutArray b Source #

# Input pointers

newtype In a Source #

In by-ref parameter; memory is allocated and freed by caller

Constructors

In (Ptr a) |

#### Instances

Instances details

WrappedPtr In Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> In a Source # unwrapPtr :: In a -> Ptr a Source # nullWrappedPtr :: In a Source # castWrappedPtr :: In a -> In b Source #
Storable (In a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

sizeOf :: In a -> Int Source #

alignment :: In a -> Int Source #

peekElemOff :: Ptr (In a) -> Int -> IO (In a) Source #

pokeElemOff :: Ptr (In a) -> Int -> In a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (In a) Source #

pokeByteOff :: Ptr b -> Int -> In a -> IO () Source #

peek :: Ptr (In a) -> IO (In a) Source #

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

Show (In a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods showsPrec :: Int -> In a -> ShowS Source # show :: In a -> String Source # showList :: [In a] -> ShowS Source #
Eq (In a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods (==) :: In a -> In a -> Bool Source # (/=) :: In a -> In a -> Bool Source #
Ord (In a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods compare :: In a -> In a -> Ordering Source # (<) :: In a -> In a -> Bool Source # (<=) :: In a -> In a -> Bool Source # (>) :: In a -> In a -> Bool Source # (>=) :: In a -> In a -> Bool Source # max :: In a -> In a -> In a Source # min :: In a -> In a -> In a Source #

newtype InArray a Source #

In by-ref array; memory is allocated and freed by caller

Constructors

InArray (Ptr a) |

#### Instances

Instances details

WrappedPtr InArray Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> InArray a Source # unwrapPtr :: InArray a -> Ptr a Source # nullWrappedPtr :: InArray a Source # castWrappedPtr :: InArray a -> InArray b Source #
Storable (InArray a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

sizeOf :: InArray a -> Int Source #

alignment :: InArray a -> Int Source #

peekElemOff :: Ptr (InArray a) -> Int -> IO (InArray a) Source #

pokeElemOff :: Ptr (InArray a) -> Int -> InArray a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (InArray a) Source #

pokeByteOff :: Ptr b -> Int -> InArray a -> IO () Source #

peek :: Ptr (InArray a) -> IO (InArray a) Source #

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

Show (InArray a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods showsPrec :: Int -> InArray a -> ShowS Source # show :: InArray a -> String Source # showList :: [InArray a] -> ShowS Source #
Eq (InArray a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods (==) :: InArray a -> InArray a -> Bool Source # (/=) :: InArray a -> InArray a -> Bool Source #
Ord (InArray a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

compare :: InArray a -> InArray a -> Ordering Source #

(<) :: InArray a -> InArray a -> Bool Source #

(<=) :: InArray a -> InArray a -> Bool Source #

(>) :: InArray a -> InArray a -> Bool Source #

(>=) :: InArray a -> InArray a -> Bool Source #

max :: InArray a -> InArray a -> InArray a Source #

min :: InArray a -> InArray a -> InArray a Source #

withIn :: (Storable a, MonadBaseControl IO m) => a -> (In a -> m b) -> m b Source #

withInList :: (Storable a, MonadBaseControl IO m) => [a] -> (InArray a -> m b) -> m b Source #

withInVector :: (Storable a, MonadBaseControl IO m) => Vector a -> (InArray a -> m b) -> m b Source #

withInMVector :: (Storable a, MonadBaseControl IO m) => IOVector a -> (InArray a -> m b) -> m b Source #

# Output pointers

newtype Out a Source #

Out by-ref parameter; memory is allocated and freed by caller

Constructors

Out (Ptr a) |

#### Instances

Instances details

WrappedPtr Out Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> Out a Source # unwrapPtr :: Out a -> Ptr a Source # nullWrappedPtr :: Out a Source # castWrappedPtr :: Out a -> Out b Source #
Storable (Out a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

sizeOf :: Out a -> Int Source #

alignment :: Out a -> Int Source #

peekElemOff :: Ptr (Out a) -> Int -> IO (Out a) Source #

pokeElemOff :: Ptr (Out a) -> Int -> Out a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Out a) Source #

pokeByteOff :: Ptr b -> Int -> Out a -> IO () Source #

peek :: Ptr (Out a) -> IO (Out a) Source #

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

Show (Out a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods showsPrec :: Int -> Out a -> ShowS Source # show :: Out a -> String Source # showList :: [Out a] -> ShowS Source #
Eq (Out a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods (==) :: Out a -> Out a -> Bool Source # (/=) :: Out a -> Out a -> Bool Source #
Ord (Out a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods compare :: Out a -> Out a -> Ordering Source # (<) :: Out a -> Out a -> Bool Source # (<=) :: Out a -> Out a -> Bool Source # (>) :: Out a -> Out a -> Bool Source # (>=) :: Out a -> Out a -> Bool Source # max :: Out a -> Out a -> Out a Source # min :: Out a -> Out a -> Out a Source #

newtype OutArray a Source #

Out by-ref array; length is specified by caller, memory is allocated and freed by caller

Constructors

OutArray (Ptr a) |

#### Instances

Instances details

WrappedPtr OutArray Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> OutArray a Source # unwrapPtr :: OutArray a -> Ptr a Source # nullWrappedPtr :: OutArray a Source # castWrappedPtr :: OutArray a -> OutArray b Source #
Storable (OutArray a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

sizeOf :: OutArray a -> Int Source #

alignment :: OutArray a -> Int Source #

peekElemOff :: Ptr (OutArray a) -> Int -> IO (OutArray a) Source #

pokeElemOff :: Ptr (OutArray a) -> Int -> OutArray a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (OutArray a) Source #

pokeByteOff :: Ptr b -> Int -> OutArray a -> IO () Source #

peek :: Ptr (OutArray a) -> IO (OutArray a) Source #

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

Show (OutArray a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods showsPrec :: Int -> OutArray a -> ShowS Source # show :: OutArray a -> String Source # showList :: [OutArray a] -> ShowS Source #
Eq (OutArray a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods (==) :: OutArray a -> OutArray a -> Bool Source # (/=) :: OutArray a -> OutArray a -> Bool Source #
Ord (OutArray a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

compare :: OutArray a -> OutArray a -> Ordering Source #

(<) :: OutArray a -> OutArray a -> Bool Source #

(<=) :: OutArray a -> OutArray a -> Bool Source #

(>) :: OutArray a -> OutArray a -> Bool Source #

(>=) :: OutArray a -> OutArray a -> Bool Source #

max :: OutArray a -> OutArray a -> OutArray a Source #

min :: OutArray a -> OutArray a -> OutArray a Source #

withOut :: (Storable a, MonadBaseControl IO m, MonadIO m) => (Out a -> m b) -> m (a, b) Source #

withMaybeOut :: (Storable a, MonadBaseControl IO m, MonadIO m) => (Out a -> m Bool) -> m (Maybe a) Source #

withOut_ :: (Storable a, MonadBaseControl IO m, MonadIO m) => (Out a -> m b) -> m a Source #

withOutMVector :: (Storable a, MonadBaseControl IO m) => IOVector a -> (Int -> OutArray a -> m b) -> m b Source #

withOutVector :: (Storable a, MonadBaseControl IO m, MonadIO m) => Int -> (OutArray a -> m b) -> m (Vector a, b) Source #

withOutVector_ :: Storable a => Int -> (OutArray a -> IO b) -> IO (Vector a) Source #

withOutVector' :: (Storable a, Integral b) => Int -> (OutArray a -> IO b) -> IO (Vector a) Source #

withOutList :: (Storable a, MonadIO m) => Int -> (OutArray a -> m b) -> m ([a], b) Source #

withOutList_ :: (Storable a, MonadIO m) => Int -> (OutArray a -> m b) -> m [a] Source #

withOutList' :: (Storable a, MonadIO m) => Int -> (OutArray a -> m Int) -> m ([a], Int) Source #

withOutList0 :: (Storable a, Eq a, MonadIO m) => a -> Int -> (OutArray a -> m b) -> m ([a], b) Source #

`withOutList0 zero n f`: allocate an array large enough to hold `n` elements, plus one extra spot for a terminator. Calls `f` with that buffer, which is expected to fill it with up to `n` elements, followed by `zero`. The elements are then read out into a list.

withOutByteString :: (MonadBaseControl IO m, MonadIO m, Integral a, Integral b) => (OutArray CChar -> a -> m b) -> m ByteString Source #

Get a `ByteString` from a function using the common "buffer and size in, bytes written out" convention.

Calls the function twice; once with a null pointer to discover the length needed and once more to actually read out the string.

withOutByteString' :: (MonadBaseControl IO m, MonadIO m, Integral a, Integral b) => (OutArray CChar -> a -> m b) -> m ByteString Source #

Variant of withOutByteString which expects the discovered length to be one byte less than the required buffer size. As required for H5Fget_name

# Bidirectional pointers

newtype InOut a Source #

In-out parameter. Memory is allocated and freed by caller.

Constructors

InOut (Ptr a) |

#### Instances

Instances details

WrappedPtr InOut Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> InOut a Source # unwrapPtr :: InOut a -> Ptr a Source # nullWrappedPtr :: InOut a Source # castWrappedPtr :: InOut a -> InOut b Source #
Storable (InOut a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

sizeOf :: InOut a -> Int Source #

alignment :: InOut a -> Int Source #

peekElemOff :: Ptr (InOut a) -> Int -> IO (InOut a) Source #

pokeElemOff :: Ptr (InOut a) -> Int -> InOut a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (InOut a) Source #

pokeByteOff :: Ptr b -> Int -> InOut a -> IO () Source #

peek :: Ptr (InOut a) -> IO (InOut a) Source #

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

Show (InOut a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods showsPrec :: Int -> InOut a -> ShowS Source # show :: InOut a -> String Source # showList :: [InOut a] -> ShowS Source #
Eq (InOut a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods (==) :: InOut a -> InOut a -> Bool Source # (/=) :: InOut a -> InOut a -> Bool Source #
Ord (InOut a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods compare :: InOut a -> InOut a -> Ordering Source # (<) :: InOut a -> InOut a -> Bool Source # (<=) :: InOut a -> InOut a -> Bool Source # (>) :: InOut a -> InOut a -> Bool Source # (>=) :: InOut a -> InOut a -> Bool Source # max :: InOut a -> InOut a -> InOut a Source # min :: InOut a -> InOut a -> InOut a Source #

newtype InOutArray a Source #

Constructors

InOutArray (Ptr a) |

#### Instances

Instances details

WrappedPtr InOutArray Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods wrapPtr :: Ptr a -> InOutArray a Source # unwrapPtr :: InOutArray a -> Ptr a Source # nullWrappedPtr :: InOutArray a Source # castWrappedPtr :: InOutArray a -> InOutArray b Source #
Storable (InOutArray a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

sizeOf :: InOutArray a -> Int Source #

alignment :: InOutArray a -> Int Source #

peekElemOff :: Ptr (InOutArray a) -> Int -> IO (InOutArray a) Source #

pokeElemOff :: Ptr (InOutArray a) -> Int -> InOutArray a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (InOutArray a) Source #

pokeByteOff :: Ptr b -> Int -> InOutArray a -> IO () Source #

peek :: Ptr (InOutArray a) -> IO (InOutArray a) Source #

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

Show (InOutArray a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods showsPrec :: Int -> InOutArray a -> ShowS Source # show :: InOutArray a -> String Source # showList :: [InOutArray a] -> ShowS Source #
Eq (InOutArray a) Source # |
Instance details Defined in Foreign.Ptr.Conventions Methods (==) :: InOutArray a -> InOutArray a -> Bool Source # (/=) :: InOutArray a -> InOutArray a -> Bool Source #
Ord (InOutArray a) Source # |

Instance details

Defined in Foreign.Ptr.Conventions

Methods

compare :: InOutArray a -> InOutArray a -> Ordering Source #

(<) :: InOutArray a -> InOutArray a -> Bool Source #

(<=) :: InOutArray a -> InOutArray a -> Bool Source #

(>) :: InOutArray a -> InOutArray a -> Bool Source #

(>=) :: InOutArray a -> InOutArray a -> Bool Source #

max :: InOutArray a -> InOutArray a -> InOutArray a Source #

min :: InOutArray a -> InOutArray a -> InOutArray a Source #

withInOut :: (Storable a, MonadBaseControl IO m, MonadIO m) => a -> (InOut a -> m b) -> m (a, b) Source #

withInOut_ :: (Storable a, MonadBaseControl IO m, MonadIO m) => a -> (InOut a -> m b) -> m a Source #

withInOutList :: (Storable a, MonadIO m) => Int -> [a] -> (InOutArray a -> m (Int, b)) -> m ([a], b) Source #

withInOutList_ :: (Storable a, MonadIO m) => Int -> [a] -> (InOutArray a -> m Int) -> m [a] Source #