ptr-0.16.2: Abstractions for operations on pointers

Safe HaskellNone
LanguageHaskell2010

Ptr.PokeAndPeek

Synopsis

Documentation

data PokeAndPeek input output Source #

Encoder and decoder of the same binary representation.

You can compose both the covariant and contravariant parameters of PokeAndPeek using Applicative and Profunctor. E.g.,

word8AndWord32 :: PokeAndPeek (Word8, Word32) (Word8, Word32)
word8AndWord32 =
  (,) <$> lmap fst word8 <*> lmap snd beWord32

Constructors

PokeAndPeek !Int (Ptr Word8 -> input -> IO ()) (Ptr Word8 -> IO output) 

Instances

Profunctor PokeAndPeek Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> PokeAndPeek b c -> PokeAndPeek a d #

lmap :: (a -> b) -> PokeAndPeek b c -> PokeAndPeek a c #

rmap :: (b -> c) -> PokeAndPeek a b -> PokeAndPeek a c #

(#.) :: Coercible * c b => (b -> c) -> PokeAndPeek a b -> PokeAndPeek a c #

(.#) :: Coercible * b a => PokeAndPeek b c -> (a -> b) -> PokeAndPeek a c #

Functor (PokeAndPeek input) Source # 

Methods

fmap :: (a -> b) -> PokeAndPeek input a -> PokeAndPeek input b #

(<$) :: a -> PokeAndPeek input b -> PokeAndPeek input a #

Applicative (PokeAndPeek input) Source # 

Methods

pure :: a -> PokeAndPeek input a #

(<*>) :: PokeAndPeek input (a -> b) -> PokeAndPeek input a -> PokeAndPeek input b #

(*>) :: PokeAndPeek input a -> PokeAndPeek input b -> PokeAndPeek input b #

(<*) :: PokeAndPeek input a -> PokeAndPeek input b -> PokeAndPeek input a #

type InvPokeAndPeek value = PokeAndPeek value value Source #

A codec, which encodes and decodes the same type. E.g.,

word8AndWord32 :: InvPokeAndPeek (Word8, Word32)
word8AndWord32 =
  (,) <$> lmap fst word8 <*> lmap snd beWord32