IdrisDoc: Effect.Memory

# Effect.Memory

data MemoryChunk : Nat -> Nat -> Type
  CH : Ptr -> MemoryChunk size initialized
data MoveDescriptor : Type
  Dst : MoveDescriptor
  Src : MoveDescriptor
RAW_MEMORY : Type -> EFFECT
data RawMemory : Effect
  Allocate : (n : Nat) -> RawMemory () () (\v => MemoryChunk n (fromInteger 0))
  Free : RawMemory () (MemoryChunk n i) (\v => ())
  Initialize : Bits8 -> (size : Nat) -> So (i + size <= n) -> RawMemory () (MemoryChunk n i) (\v => MemoryChunk n (i + size))
  Peek : (offset : Nat) -> (size : Nat) -> So (offset + size <= i) -> RawMemory (Vect size Bits8) (MemoryChunk n i) (\v => MemoryChunk n i)
  Poke : (offset : Nat) -> Vect size Bits8 -> So (offset <= i && Delay (offset + size <= n)) -> RawMemory () (MemoryChunk n i) (\v => MemoryChunk n (max i (offset + size)))
  Move : (src : MemoryChunk src_size src_init) -> (dst_offset : Nat) -> (src_offset : Nat) -> (size : Nat) -> So (dst_offset <= dst_init && Delay (dst_offset + size <= dst_size)) -> So (src_offset + size <= src_init) -> RawMemory () (MemoryChunk dst_size dst_init) (\v => MemoryChunk dst_size (max dst_init (dst_offset + size)))
  GetRawPtr : RawMemory (MemoryChunk n i) (MemoryChunk n i) (\v => MemoryChunk n i)
allocate : (n : Nat) -> Eff () [RAW_MEMORY ()] (\v => [RAW_MEMORY (MemoryChunk n (fromInteger 0))])
free : Eff () [RAW_MEMORY (MemoryChunk n i)] (\v => [RAW_MEMORY ()])
initialize : Bits8 -> (size : Nat) -> So (i + size <= n) -> Eff () [RAW_MEMORY (MemoryChunk n i)] (\v => [RAW_MEMORY (MemoryChunk n (i + size))])
move : (dst_offset : Nat) -> (src_offset : Nat) -> (size : Nat) -> So (dst_offset <= dst_init && Delay (dst_offset + size <= dst_size)) -> So (src_offset + size <= src_init) -> Eff () [Dst ::: RAW_MEMORY (MemoryChunk dst_size dst_init), Src ::: RAW_MEMORY (MemoryChunk src_size src_init)] (\v => [Dst ::: RAW_MEMORY (MemoryChunk dst_size (max dst_init (dst_offset + size))), Src ::: RAW_MEMORY (MemoryChunk src_size src_init)])
peek : (offset : Nat) -> (size : Nat) -> So (offset + size <= i) -> Eff (Vect size Bits8) [RAW_MEMORY (MemoryChunk n i)] (\result => [RAW_MEMORY (MemoryChunk n i)])
poke : (offset : Nat) -> Vect size Bits8 -> So (offset <= i && Delay (offset + size <= n)) -> Eff () [RAW_MEMORY (MemoryChunk n i)] (\v => [RAW_MEMORY (MemoryChunk n (max i (offset + size)))])