diff --git a/kklib/include/kklib/ref.h b/kklib/include/kklib/ref.h index 7038009d9..5ff8ce417 100644 --- a/kklib/include/kklib/ref.h +++ b/kklib/include/kklib/ref.h @@ -84,7 +84,7 @@ static inline kk_unit_t kk_ref_set_borrow(kk_ref_t r, kk_box_t value, kk_context } // In Koka we can constrain the argument of f to be a local-scope reference. -static inline kk_box_t kk_ref_modify(kk_ref_t r, kk_function_t f, kk_context_t* ctx) { +static inline kk_box_t kk_ref_access(kk_ref_t r, kk_function_t f, kk_context_t* ctx) { return kk_function_call(kk_box_t,(kk_function_t,kk_ref_t,kk_context_t*),f,(f,r,ctx),ctx); } diff --git a/lib/std/core/types.kk b/lib/std/core/types.kk index e99324646..a2f08aa61 100644 --- a/lib/std/core/types.kk +++ b/lib/std/core/types.kk @@ -351,15 +351,23 @@ pub inline extern ref/(!)( ref : ref, ?hdiv : hdiv) : ( ref : ref, f : forall local-var -> |e> b, ?hdiv : hdiv) : ,write|e> b - c inline "kk_ref_modify(#1,#2,kk_context())" +pub inline extern access( ref : ref, f : forall local-var -> |e> b, ?hdiv : hdiv) : ,write|e> b + c inline "kk_ref_access(#1,#2,kk_context())" js inline "((#2)(#1))" +// Deprecated: alias for `access` +pub inline extern modify( ref : ref, f : forall local-var -> |e> b, ?hdiv : hdiv) : ,write|e> b + c "kk_ref_access" + // If a heap effect is unobservable, the heap effect can be erased by using the `run` fun. // See also: _State in Haskell, by Simon Peyton Jones and John Launchbury_. pub extern run( action : forall () -> ,read,write | e> a ) : e a diff --git a/test/lib/ref-modify.kk b/test/lib/ref-access.kk similarity index 60% rename from test/lib/ref-modify.kk rename to test/lib/ref-access.kk index b6a5adaca..a2b332d88 100644 --- a/test/lib/ref-modify.kk +++ b/test/lib/ref-access.kk @@ -1,5 +1,5 @@ fun main() { val r = ref(0) - r.modify( fn(l) l := 1 ) + r.access( fn(l) l := 1 ) (!r).println -} \ No newline at end of file +} diff --git a/test/lib/ref-modify.kk.out b/test/lib/ref-access.kk.out similarity index 100% rename from test/lib/ref-modify.kk.out rename to test/lib/ref-access.kk.out