forgot to add file modules/ref.mlw in commit 05ca6beb...

parent f07301e9
(* References *)
module Ref
type ref 'a = {| mutable contents : 'a |}
parameter ref : v:'a -> {} ref 'a { result=v }
parameter (!) : r:ref 'a -> {} 'a reads r { result=r }
parameter (:=) : r:ref 'a -> v:'a -> {} unit writes r { r=v }
end
module Refint
use export int.Int
use export module Ref
parameter incr : r:ref int -> {} unit writes r { r = old r + 1 }
parameter decr : r:ref int -> {} unit writes r { r = old r - 1 }
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment