mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-21 02:31:50 +03:00
19 lines
397 B
Idris
19 lines
397 B
Idris
import Data.Buffer
|
|
|
|
export
|
|
data ForeignPtr : Type -> Type where
|
|
MkFP : Buffer -> ForeignPtr a
|
|
|
|
public export
|
|
interface Storable a where
|
|
size : Int
|
|
|
|
peekByteOff : HasIO io => ForeignPtr a -> Int -> io a
|
|
|
|
peekElemOff : HasIO io => ForeignPtr a -> Int -> io a
|
|
peekElemOff fp off = peekByteOff fp (off * size {a})
|
|
|
|
Storable Bits8 where
|
|
size = 8
|
|
peekByteOff (MkFP b) off = getBits8 b off
|