@@ -24,11 +24,11 @@ data RawMemory : Effect where
24 (size : Nat) ->
24 (size : Nat) ->
25 So (offset + size <= i) ->
25 So (offset + size <= i) ->
26 RawMemory (Vect size Bits8)
26 RawMemory (Vect size Bits8)
27− (MemoryChunk n i) (\v => MemoryChunk n i)
27+ (MemoryChunk n i) (\v => MemoryChunk n i)
28 Poke : (offset : Nat) ->
28 Poke : (offset : Nat) ->
29 (Vect size Bits8) ->
29 (Vect size Bits8) ->
30 So (offset <= i && offset + size <= n) ->
30 So (offset <= i && offset + size <= n) ->
31− RawMemory () (MemoryChunk n i) (\v => MemoryChunk n (max i (offset + size)))
31+ RawMemory () (MemoryChunk n i) (\v => MemoryChunk n (max i (offset + size)))
32 Move : (src : MemoryChunk src_size src_init) ->
32 Move : (src : MemoryChunk src_size src_init) ->
33 (dst_offset : Nat) ->
33 (dst_offset : Nat) ->
34 (src_offset : Nat) ->
34 (src_offset : Nat) ->
@@ -36,8 +36,8 @@ data RawMemory : Effect where
36 So (dst_offset <= dst_init && dst_offset + size <= dst_size) ->
36 So (dst_offset <= dst_init && dst_offset + size <= dst_size) ->
37 So (src_offset + size <= src_init) ->
37 So (src_offset + size <= src_init) ->
38 RawMemory () (MemoryChunk dst_size dst_init)
38 RawMemory () (MemoryChunk dst_size dst_init)
39− (\v => MemoryChunk dst_size (max dst_init (dst_offset + size)))
39+ (\v => MemoryChunk dst_size (max dst_init (dst_offset + size)))
40− GetRawPtr : RawMemory (MemoryChunk n i) (MemoryChunk n i) (\v => MemoryChunk n i)
40+ GetRawPtr : RawMemory (MemoryChunk n i) (MemoryChunk n i) (\v => MemoryChunk n i)
43do_malloc : Nat -> IOExcept String Ptr
43do_malloc : Nat -> IOExcept String Ptr
@@ -84,9 +84,9 @@ instance Handler RawMemory (IOExcept String) where
84 = do ptr <- do_malloc n
84 = do ptr <- do_malloc n
85 k () (CH ptr)
85 k () (CH ptr)
86 handle {-{res = MemoryChunk _ offset}-} (CH ptr) (Initialize {i} c size _) k
86 handle {-{res = MemoryChunk _ offset}-} (CH ptr) (Initialize {i} c size _) k
87− = ioe_lift (do_memset ptr i c size) $> k () (CH ptr)
87+ = ioe_lift (do_memset ptr i c size) *> k () (CH ptr)
88 handle (CH ptr) (Free) k
88 handle (CH ptr) (Free) k
89− = ioe_lift (do_free ptr) $> k () ()
89+ = ioe_lift (do_free ptr) *> k () ()
90 handle (CH ptr) (Peek offset size _) k
90 handle (CH ptr) (Peek offset size _) k
91 = do res <- ioe_lift (do_peek ptr offset size)
91 = do res <- ioe_lift (do_peek ptr offset size)
92 k res (CH ptr)
92 k res (CH ptr)
@@ -102,7 +102,7 @@ instance Handler RawMemory (IOExcept String) where
102RAW_MEMORY : Type -> EFFECT
102RAW_MEMORY : Type -> EFFECT
103RAW_MEMORY t = MkEff t RawMemory
103RAW_MEMORY t = MkEff t RawMemory
105−allocate : (n : Nat) ->
105+allocate : (n : Nat) ->
106 Eff () [RAW_MEMORY ()] (\v => [RAW_MEMORY (MemoryChunk n 0)])
106 Eff () [RAW_MEMORY ()] (\v => [RAW_MEMORY (MemoryChunk n 0)])
107allocate size = call $ Allocate size
107allocate size = call $ Allocate size
@@ -111,7 +111,7 @@ initialize : {i : Nat} ->
112 (size : Nat) ->
112 (size : Nat) ->
113 So (i + size <= n) ->
113 So (i + size <= n) ->
114− Eff () [RAW_MEMORY (MemoryChunk n i)]
114+ Eff () [RAW_MEMORY (MemoryChunk n i)]
115 (\v => [RAW_MEMORY (MemoryChunk n (i + size))])
115 (\v => [RAW_MEMORY (MemoryChunk n (i + size))])
116initialize c size prf = call $ Initialize c size prf
116initialize c size prf = call $ Initialize c size prf
@@ -122,7 +122,7 @@ peek : {i : Nat} ->
122 (offset : Nat) ->
122 (offset : Nat) ->
123 (size : Nat) ->
123 (size : Nat) ->
124 So (offset + size <= i) ->
124 So (offset + size <= i) ->
125− { [RAW_MEMORY (MemoryChunk n i)] } Eff (Vect size Bits8)
125+ { [RAW_MEMORY (MemoryChunk n i)] } Eff (Vect size Bits8)
126peek offset size prf = call $ Peek offset size prf
126peek offset size prf = call $ Peek offset size prf
128poke : {n : Nat} ->
128poke : {n : Nat} ->
@@ -130,12 +130,12 @@ poke : {n : Nat} ->
130 (offset : Nat) ->
130 (offset : Nat) ->
131 Vect size Bits8 ->
131 Vect size Bits8 ->
132 So (offset <= i && offset + size <= n) ->
132 So (offset <= i && offset + size <= n) ->
133− Eff () [RAW_MEMORY (MemoryChunk n i)]
133+ Eff () [RAW_MEMORY (MemoryChunk n i)]
134 (\v => [RAW_MEMORY (MemoryChunk n (max i (offset + size)))])
134 (\v => [RAW_MEMORY (MemoryChunk n (max i (offset + size)))])
135poke offset content prf = call $ Poke offset content prf
135poke offset content prf = call $ Poke offset content prf
138−getRawPtr : { [RAW_MEMORY (MemoryChunk n i)] } Eff (MemoryChunk n i)
138+getRawPtr : { [RAW_MEMORY (MemoryChunk n i)] } Eff (MemoryChunk n i)
139getRawPtr = call $ GetRawPtr
139getRawPtr = call $ GetRawPtr
@@ -173,5 +173,5 @@ move : {dst_size : Nat} ->
173move dst_offset src_offset size dst_bounds src_bounds
173move dst_offset src_offset size dst_bounds src_bounds
174 = do src_ptr <- Src :- getRawPtr
174 = do src_ptr <- Src :- getRawPtr
175 Dst :- move' src_ptr dst_offset src_offset size dst_bounds src_bounds
175 Dst :- move' src_ptr dst_offset src_offset size dst_bounds src_bounds
176− return ()
176+ return ()