/*---------------------------------------------------------------------------
  Copyright 2012-2024, Microsoft Research, Daan Leijen.

  This is free software; you can redistribute it and/or modify it under the
  terms of the Apache License, Version 2.0. A copy of the License can be
  found in the LICENSE file at the root of this distribution.
---------------------------------------------------------------------------*/

/* Internal effect handler primitives.

  Internal primitives to implement evidence based algebraic
  effect handlers. These are emitted by the compiler during evidence
  translation and this module is always implicitly imported.

  This module is compiled _without monadic translation_ and
  thus we need to do this by hand in this module which allows us to implement
  most primitives directly in Koka keeping the external C/JavaScript/etc primitives
  to a minimum.

  The paper:

  > Ningning Xie, and Daan Leijen. _Generalized Evidence Passing for Effect Handlers_,
  > or _efficient compilation of effect handlers to C_.
  > Proceedings of the ACM International Conference on Functional Programming (ICFP'21),
  > August 2021, Vol 5: pp. 71, doi: 10.1145/3473576.
  > <https://www.microsoft.com/en-us/research/publication/generalized-evidence-passing-for-effect-handlers-or-efficient-compilation-of-effect-handlers-to-c/>

  describes precisely how the monadic evidence translation works on which this
  module is based. Read this first to understand how this module works.

  Another paper of interest is:

  > Ningning Xie, and Daan Leijen. _Effect Handlers in Haskell, Evidently_.
  > The 13th ACM SIGPLAN International Haskell Symposium, (Haskell'20),
  > August 2020. <https://www.microsoft.com/en-us/research/uploads/prod/2020/07/effev.pdf>

  which which explains the internal typing of handlers, evidence vectors, etc. in a simpler setting.

  ## Notes

  An effect _row_ has kind `::E`, while an atomic effect kind is `::X`.
  (We will see that `::X` is equal to the kind `::(E,V) -> V` ) (`::V` is for value kinds *)

  We use the term "answer" context to talk about the result type `:r` and effect type `:e` of
  (the context of) the handler in the stack. The `:e` does not include the effect `::X` of the handler.

  - `:marker<e,r>` : a unique integer corresponding to an answer context `:<e,r>`. This functions
    as a dependent type: when the integer matches at runtime, that will be the type of the answer context.

  - handlers `:h` are partially applied types with signature `h<e,r> :: (E,V)->V`
    for some answer context `:<e,r>`. The handlers contain all operations (much like a virtual method table).
    (these handler types are generated by the compiler for each effect type)

  - Evidence `ev<h :: (E,V)->V >` for a handler `:h` is an existential tuple
    `forall e r. Ev( marker: marker<e,r>, hnd: h<e,r> )` containing the marker and the actual handler (pointer)
    for some answer context `:<e,r>` -- we don't know the answer context exact type as it depends on where
    the handler was dynamically bound; we just have evidence that this handler `:h` exists in our context.

  - Actually, we use a quadruple for the evidence (corresponding to the evidence as formalized in the generalized evidence paper).
    We also add the handler effect tag (`:htag<h>`) (for dynamic lookup), and the evidence vector
    of the answer context where the handler was defined (`:evv<e,r>`)
    (so we can execute operations in-place using the evidence vector at the point where they were defined).

  - Each operation definition in a handler is called a _clause_. For a one argument operation, we have:
    ```
    abstract value type clause1<a,b,h,e::E,r>
      Clause1( clause: (marker<e,r>, ev<h>, a) -> e b )
    ```
    defining an operation `:a -> b` for some handler `:h` in an answer context `:<e,r>`.
    (these are generated by the compiler from a handler definition)

  - An operation is performed by a rank-2 function:
    `fun perform1( ev : ev<h>, select-op : (forall<e1,r> h<e1,r> -> clause1<a,b,h,e1,r>), x : a ) : e b`
    where we can call an operation given evidence for a handler `:ev<h>` together with a
    polymorphic field selection function that for any handler `h` in _any_ answer context, returns its clause.
    It is defined as:
    ```
      match ev
        Ev(_tag,m,h,_answ) -> match select-op(h)  // for an abstract `:<e1,r>`
          Clause1(f) -> f(m,ev,x)
    ```

  - Each clause _definition_ can now determine to fully yield to the handler, or be tail-resumptive etc.
    (that is, this is determined at the handler definition site, not the call site, and generated by the compiler)
    For example, we could be most general (`ctl`) and yield back to the marker (where the handler was defined in the call-stack)
    (with a function that receives the continuation/resumption `k`):
    ```
    Clause1( fn(m,ev,x) yield-to(m, fn(k) op(k,x) ))
    ```
    or be super efficient and directly call the (tail-resumptive) operation in-place (`fun`):
    ```
    Clause1( fn(m,ev,x) op(x) )
    ```
    and various variants in-between. The last definition is unsafe for example if the (user defined) `op` invokes
    operations itself as the evidence vector should be the one as defined at the handler site.
    So, we normally use instead:
    ```
    Clause1( fn(m,ev,x) under1(ev,op,x) )
    ```
    where `under1` uses the evidence vector (`hevv`) stored in the evidence `ev` to execute `op(x)` under.
    (this is also explained in detail in the generalized evidence paper).

*/
module std/core/hndstd/core/hnd

import std/core/typesstd/core/types
import std/core/undivstd/core/undiv

extern import
  c  file "inline/hnd"
  js file "inline/hnd.js"

// -------------------------------------------
// Internal types
// -------------------------------------------

// The tag of a handler identifies the type at runtime (e.g. `"exn/core/std"`).
abstract value type htagstd/core/hnd/htag: ((E, V) -> V) -> V<hh: (E, V) -> V::(E,V)->V>
  Htagstd/core/hnd/Htag: forall<a> (tagname : string) -> htag<a>(tagnamestd/core/hnd/htag/tagname: forall<a> (htag : htag<a>) -> string:stringstd/core/types/string: V)

// _Internal_ hidden constructor for creating handler tags
pub fun @new-htag( tagtag: string : stringstd/core/types/string: V )result: -> total htag<1921> : htagstd/core/hnd/htag: ((E, V) -> V) -> V<hh: (E, V) -> V>
  Htagstd/core/hnd/Htag: forall<a> (tagname : string) -> htag<a>(tagtag: string)

// Show a handler tag.
pub fun htag/showstd/core/hnd/htag/show: forall<a> (htag<a>) -> string( Htagstd/core/hnd/Htag: forall<a> (tagname : string) -> htag<a>(tagtag: string) : htagstd/core/hnd/htag: ((E, V) -> V) -> V<hh: (E, V) -> V> )result: -> total string : stringstd/core/types/string: V
  tagtag: string


// Effect handler evidence of a handler `:h` in the context.
abstract type evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>
  con Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a><ee: E,rr: V>(htagstd/core/hnd/ev/htag: forall<a> (ev : ev<a>) -> htag<a>:htagstd/core/hnd/htag: ((E, V) -> V) -> V<hh: (E, V) -> V>, marker:markerstd/core/hnd/marker: (E, V) -> V<ee: E,rr: V>, hnd:hh: (E, V) -> V<ee: E,rr: V>, hevv:evvstd/core/hnd/evv: E -> V<ee: E>)

// Abstract type of Evidence vectors
type evvstd/core/hnd/evv: E -> V<ee: E::E>

// Index into an evidence vector
pub alias ev-indexstd/core/hnd/ev-index: V = ssize_tstd/core/types/ssize_t: V

// Evidence equality compares the markers.
pub fun ev/(==)std/core/hnd/ev/(==): forall<a> (ev<a>, ev<a>) -> bool( Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(_,m1m1: marker<$2095,$2096>)  : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(_,m2m2: marker<$2108,$2109>) : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V> )result: -> total bool : boolstd/core/types/bool: V
  eq-markerstd/core/hnd/eq-marker: (x : marker<$2095,$2096>, y : marker<$2108,$2109>) -> bool(m1m1: marker<$2095,$2096>,m2m2: marker<$2108,$2109>)


// -------------------------------------------
// Internal Markers
// -------------------------------------------

// _Internal_. The type of handler markers (usually `:int32_t`).
// Needed for effect handlers in `module std/core/hnd`.
value type markerstd/core/hnd/marker: (E, V) -> V<ee: E::E,aa: V>

// Are two markers equal?
extern eq-markerstd/core/hnd/eq-marker: forall<a,b,e,e1> (x : marker<e,a>, y : marker<e1,b>) -> bool( xx: marker<$2034,$2032> : markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,a1a1: V>, yy: marker<$2035,$2033> : markerstd/core/hnd/marker: (E, V) -> V<e2e2: E,a2a2: V> ) : boolstd/core/types/bool: V
  inline "#1==#2"

extern fresh-markerstd/core/hnd/fresh-marker: forall<a,e> () -> marker<e,a>() : markerstd/core/hnd/marker: (E, V) -> V<ee: E,aa: V>
  c inline "kk_marker_unique(kk_context())"
  js inline "$marker_unique++"

extern fresh-marker-namedstd/core/hnd/fresh-marker-named: forall<a,e> () -> marker<e,a>() : markerstd/core/hnd/marker: (E, V) -> V<ee: E,aa: V>
  c inline  "-kk_marker_unique(kk_context())"
  js inline "-($marker_unique++)"



// -------------------------------------------
// Internal Evidence vectors
// The datatype is `:evv<e>` is internal for performance
// reasons and since different backends may have different
// requirements.
// -------------------------------------------

// Insert new evidence into the given evidence vector.
extern evv-insertstd/core/hnd/evv-insert: forall<e,e1,a> (evv : evv<e>, ev : ev<a>) -> e evv<e1>( evvevv: evv<$2213> : evvstd/core/hnd/evv: E -> V<e1e1: E>, evev: ev<$2215> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V> ) : e1e1: E evvstd/core/hnd/evv: E -> V<e2e2: E>
  c  "kk_evv_insert"
  js "_evv_insert"

// show evidence for debug purposes
extern evv-showstd/core/hnd/evv-show: forall<e> (evv : evv<e>) -> string( evvevv: evv<$2254> : evvstd/core/hnd/evv: E -> V<ee: E> ) : stringstd/core/types/string: V
  c  "kk_evv_show"
  js "_evv_show"

// Is an evidence vector unchanged? (i.e. as pointer equality).
// This is used to avoid copying in common cases.
extern evv-eqstd/core/hnd/evv-eq: forall<e> (evv0 : evv<e>, evv1 : evv<e>) -> bool(evv0evv0: evv<$2274> : evvstd/core/hnd/evv: E -> V<ee: E>, evv1evv1: evv<$2274> : evvstd/core/hnd/evv: E -> V<ee: E> ) : boolstd/core/types/bool: V
  c  "kk_evv_eq"
  js inline "(#1) === (#2)"


// -------------------------------------------
// Operations on the "current" evidence vector
// -------------------------------------------

// Return the evidence at index `i` in the current evidence vector.
pub inline extern @evv-at<e,h> ( i : ev-indexstd/core/hnd/ev-index: V ) : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>  // pretend total; don't simplify
  c  "kk_evv_at"
  js "$std_core_hnd._evv_at"

// (dynamically) find evidence insertion/deletion index in the evidence vector
// The compiler optimizes `@evv-index` to a static index when apparent from the effect type.
pub extern @evv-index<ee: E::E,hh: (E, V) -> V>( htaghtag: htag<$2296> : htagstd/core/hnd/htag: ((E, V) -> V) -> V<hh: (E, V) -> V> ) : ee: E ev-indexstd/core/hnd/ev-index: V
  c  "kk_evv_index"
  js "__evv_index"

// Get evidence at a mask level for duplicate labels.
pub inline extern @evv-index-mask( i : ev-indexstd/core/hnd/ev-index: V, mask-level : ev-indexstd/core/hnd/ev-index: V ) : ee: E ev-indexstd/core/hnd/ev-index: V
  inline "#1+#2"

// Get the current evidence vector.
extern evv-getstd/core/hnd/evv-get: forall<e> () -> e evv<e>() : ee: E evvstd/core/hnd/evv: E -> V<ee: E>
  c  "kk_evv_get"
  js "$std_core_hnd._evv_get"

// Set the current evidence vector.
inline extern evv-setstd/core/hnd/evv-set: forall<e,e1> (w : evv<e1>) -> e ()<e1,e>( w : evvstd/core/hnd/evv: E -> V<e1e1: E> ) : ee: E (std/core/types/unit: V)std/core/types/unit: V
  c  "kk_evv_set"
  js "$std_core_hnd._evv_set"

// Does the current evidence vector consist solely of affine handlers?
// This is called in backends that do not have context paths (like javascript)
// to optimize TRMC (where we can use faster update-in-place TRMC if we know the
// operations are all affine). As such, it is always safe to return `false`.
//
// control flow context:
//                 -1: none: bottom
//                   /          \
// 0: except: never resumes   1: linear: resumes exactly once
//                   \          /
//           2: affine: resumes never or once
//                        |
//     3: multi: resumes never, once, or multiple times
//
pub extern @evv-is-affine() : boolstd/core/types/bool: V
  c  inline "kk_evv_is_affine(kk_context())"
  js inline "$std_core_hnd._evv_is_affine_()"


// -----------------------------------------------------------------------------------
// Various swap variants.
// These are here just for improved performance (by avoiding dup/drop for example)
// -----------------------------------------------------------------------------------

// Swap the current evidence vector with `w`
inline extern evv-swapstd/core/hnd/evv-swap: forall<e,e1,e2> (w : evv<e1>) -> e evv<e2><e1,e2>( w : evvstd/core/hnd/evv: E -> V<e1e1: E> ) : ee: E evvstd/core/hnd/evv: E -> V<e2e2: E>
  c  "kk_evv_swap"
  js "$std_core_hnd._evv_swap"

// Remove evidence at index `i` of the current evidence vector, and return the old one.
// (used by `mask`)
extern evv-swap-deletestd/core/hnd/evv-swap-delete: forall<e,e1> (i : ev-index, behind : bool) -> e1 evv<e>( ii: ev-index : ev-indexstd/core/hnd/ev-index: V, behindbehind: bool : boolstd/core/types/bool: V ) : e1e1: E evvstd/core/hnd/evv: E -> V<ee: E>
  c  "kk_evv_swap_delete"
  js "_evv_swap_delete"

// Swap the current evidence vector with an empty vector.
// (this is used in open calls to switch to a total context)
inline extern evv-swap-create0std/core/hnd/evv-swap-create0: forall<e> () -> e evv<e>() : ee: E evvstd/core/hnd/evv: E -> V<ee: E>  //not quite the right effect type but avoids unbound effect types
  c  "kk_evv_swap_create0"
  js "$std_core_hnd._evv_swap_create0"

// Swap the current evidence vector with a singleton vector (with the evidence at current index `i`).
// (this is common in open calls to switch to a singleton effect context when calling operations)
inline extern evv-swap-create1std/core/hnd/evv-swap-create1: forall<e> (i : ev-index) -> e evv<e>( i : ev-indexstd/core/hnd/ev-index: V ) : ee: E evvstd/core/hnd/evv: E -> V<ee: E>  //not quite the right effect type but avoids unbound effect types
  c  "kk_evv_swap_create1"
  js "$std_core_hnd._evv_swap_create1"

// Swap the current evidence vector with a new vector consisting of evidence
// at indices `indices` in the current vector.
extern evv-swap-createstd/core/hnd/evv-swap-create: forall<e> (indices : vector<ev-index>) -> e evv<e>( indicesindices: vector<ev-index> : vectorstd/core/types/vector: V -> V<ev-indexstd/core/hnd/ev-index: V> ) : ee: E evvstd/core/hnd/evv: E -> V<ee: E>  //not quite the right effect type but avoids unbound effect types
  c  "kk_evv_swap_create"
  js "_evv_swap_create"



// -------------------------------------------
// Internal multi-prompt delimited control
// -------------------------------------------

pub inline extern yieldingstd/core/hnd/yielding: () -> bool() : boolstd/core/types/bool: V
  c  "kk_yielding"
  js "$std_core_hnd._yielding"

pub inline extern yielding-non-finalstd/core/hnd/yielding-non-final: () -> bool() : boolstd/core/types/bool: V
  c  "kk_yielding_non_final"
  js "$std_core_hnd._yielding_non_final"

pub noinline extern yield-extendstd/core/hnd/yield-extend: forall<a,b,e> (next : (a) -> e b) -> e b(nextnext: ($2390) -> $2392 $2391 : aa: V -> ee: E bb: V ) : ee: E bb: V
  c  "kk_yield_extend"
  js "_yield_extend"

pub inline fun yield-bindstd/core/hnd/yield-bind: forall<a,b,e> (x : a, next : (a) -> e b) -> e b( xx: $2430 : aa: V, nextnext: ($2430) -> $2432 $2431 : aa: V -> ee: E bb: V )result: -> 2470 2469 : ee: E bb: V
  if yieldingstd/core/hnd/yielding: () -> $2432 bool() then yield-extendstd/core/hnd/yield-extend: (next : ($2430) -> $2432 $2431) -> $2432 $2431(nextnext: ($2430) -> $2432 $2431) else nextnext: ($2430) -> $2432 $2431(xx: $2430)

pub inline fun yield-bind2std/core/hnd/yield-bind2: forall<a,b,e> (x : a, extend : (a) -> e b, next : (a) -> e b) -> e b( xx: $2480 : aa: V, extendextend: ($2480) -> $2482 $2481 : aa: V -> ee: E bb: V, nextnext: ($2480) -> $2482 $2481 : aa: V -> ee: E bb: V )result: -> 2520 2519 : ee: E bb: V
  if yieldingstd/core/hnd/yielding: () -> $2482 bool() then yield-extendstd/core/hnd/yield-extend: (next : ($2480) -> $2482 $2481) -> $2482 $2481(extendextend: ($2480) -> $2482 $2481) else nextnext: ($2480) -> $2482 $2481(xx: $2480)

extern yield-contstd/core/hnd/yield-cont: forall<a,e,b> (f : forall<c> ((c) -> e a, c) -> e b) -> e b(ff: forall<a> ((a) -> $2531 $2530, a) -> $2531 $2532 : forall<bb: V> (bb: V -> ee: E aa: V, bb: V) -> ee: E rr: V ) : ee: E rr: V  // make hidden pub?
  c  "kk_yield_cont"
  js "_yield_cont"

inline extern keep-yielding-finalstd/core/hnd/keep-yielding-final: forall<e,a> () -> e a() : ee: E rr: V
  c  "kk_box_any"
  js inline "undefined"

extern yield-promptstd/core/hnd/yield-prompt: forall<a,e,b> (m : marker<e,b>) -> yld<e,a,b>( mm: marker<$2580,$2581>: markerstd/core/hnd/marker: (E, V) -> V<ee: E,rr: V> ) : yldstd/core/hnd/yld: (E, V, V) -> V<ee: E,aa: V,rr: V>
  c  "kk_yield_prompt"
  js "_yield_prompt"

extern yield-to-primstd/core/hnd/yield-to-prim: forall<a,e,e1,b> (m : marker<e1,b>, clause : ((resume-result<a,b>) -> e1 b) -> e1 b) -> e (() -> a)( mm: marker<$2625,$2626> : markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>, clauseclause: ((resume-result<$2623,$2626>) -> $2625 $2626) -> $2625 $2626 : (resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> e1e1: E rr: V) -> e1e1: E rr: V ) : ee: E (() -> bstd/core/types/total: E)
  c  "kk_yield_to"
  js "$std_core_hnd._yield_to"

extern yield-to-finalstd/core/hnd/yield-to-final: forall<a,e,e1,b> (m : marker<e1,b>, clause : ((resume-result<a,b>) -> e1 b) -> e1 b) -> e a( mm: marker<$2681,$2682> : markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>, clauseclause: ((resume-result<$2679,$2682>) -> $2681 $2682) -> $2681 $2682 : (resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> e1e1: E rr: V) -> e1e1: E rr: V ) : ee: E bb: V
  c  "kk_yield_final"
  js "$std_core_hnd._yield_final"

noinline fun yield-tostd/core/hnd/yield-to: forall<a,e,b> (m : marker<e,b>, clause : ((resume-result<a,b>) -> e b) -> e b) -> e a( mm: marker<$2733,$2734> : markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>, clauseclause: ((resume-result<$2732,$2734>) -> $2733 $2734) -> $2733 $2734 : (resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> e1e1: E rr: V) -> e1e1: E rr: V )result: -> 2786 2785 : e1e1: E bb: V
  //val w0 = evv-get()
  val gg: () -> $2732 : () -> _b_b: V = yield-to-primstd/core/hnd/yield-to-prim: (m : marker<$2733,$2734>, clause : ((resume-result<$2732,$2734>) -> $2733 $2734) -> $2733 $2734) -> $2733 (() -> $2732)(mm: marker<$2733,$2734>, clauseclause: ((resume-result<$2732,$2734>) -> $2733 $2734) -> $2733 $2734)
  yield-extendstd/core/hnd/yield-extend: (next : (() -> $2733 $2732) -> $2733 $2732) -> $2733 $2732 fnfn: (f : () -> $2733 $2732) -> $2733 $2732(ff: () -> $2733 $2732)
    // val keep1 = guard(w0)  // check the evidence is correctly restored
    ff: () -> $2733 $2732()

pub type yield-infostd/core/hnd/yield-info: V

extern yield-capturestd/core/hnd/yield-capture: forall<e> () -> e yield-info() : ee: E yield-infostd/core/hnd/yield-info: V
  c "kk_yield_capture"
  js "_yield_capture"

pub extern unsafe-reyieldstd/core/hnd/unsafe-reyield: forall<a,e> (yld : yield-info) -> e a(yldyld: yield-info : yield-infostd/core/hnd/yield-info: V) : ee: E aa: V
  c "kk_yield_reyield"
  js "_reyield"


// -------------------------------------------
//
// -------------------------------------------

inline extern cast-ev0std/core/hnd/cast-ev0: forall<a,e,e1> (f : () -> e1 a) -> (() -> e a)( f:() -> e1e1: E bb: V) : ((std/core/types/total: E) -> e0e0: E bb: V)
  inline "#1"

inline extern cast-ev1std/core/hnd/cast-ev1: forall<a,b,e,e1> (f : (a) -> e1 b) -> ((a) -> e b)( f:(a1a1: V) -> e1e1: E bb: V) : ((std/core/types/total: Ea1a1: V) -> e0e0: E bb: V)
  inline "#1"

inline extern cast-ev2std/core/hnd/cast-ev2: forall<a,b,c,e,e1> (f : (a, b) -> e1 c) -> ((a, b) -> e c)( f:(a1a1: V,a2a2: V) -> e1e1: E bb: V) : ((std/core/types/total: Ea1a1: V,a2a2: V) -> e0e0: E bb: V)
  inline "#1"

inline extern cast-ev3std/core/hnd/cast-ev3: forall<a,b,c,d,e,e1> (f : (a, b, c) -> e1 d) -> ((a, b, c) -> e d)( f:(a1a1: V,a2a2: V,a3a3: V) -> e1e1: E bb: V) : ((std/core/types/total: Ea1a1: V,a2a2: V,a3a3: V) -> e0e0: E bb: V)
  inline "#1"

inline extern cast-ev4std/core/hnd/cast-ev4: forall<a,b,c,d,a1,e,e1> (f : (a, b, c, d) -> e1 a1) -> ((a, b, c, d) -> e a1)( f:(a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> e1e1: E bb: V) : ((std/core/types/total: Ea1a1: V,a2a2: V,a3a3: V,a4a4: V) -> e0e0: E bb: V)
  inline "#1"

inline extern cast-ev5std/core/hnd/cast-ev5: forall<a,b,c,d,a1,b1,e,e1> (f : (a, b, c, d, a1) -> e1 b1) -> ((a, b, c, d, a1) -> e b1)( f:(a1a1: V,a2a2: V,a3a3: V,a4a4: V,a5a5: V) -> e1e1: E bb: V) : ((std/core/types/total: Ea1a1: V,a2a2: V,a3a3: V,a4a4: V,a5a5: V) -> e0e0: E bb: V)
  inline "#1"

value type resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V>
  Deepstd/core/hnd/Deep: forall<a,b> (result : a) -> resume-result<a,b>( result: bb: V )
  Shallowstd/core/hnd/Shallow: forall<a,b> (result : a) -> resume-result<a,b>( result: bb: V )
  Finalizestd/core/hnd/Finalize: forall<a,b> (result : b) -> resume-result<a,b>( result : rr: V )

value type yldstd/core/hnd/yld: (E, V, V) -> V<ee: E,aa: V,rr: V>
  Purestd/core/hnd/Pure: forall<e,a,b> yld<e,a,b>
  YieldingFinalstd/core/hnd/YieldingFinal: forall<e,a,b> yld<e,a,b>
  Yieldingstd/core/hnd/Yielding: forall<e,a,b> yld<e,a,b>
  Yieldstd/core/hnd/Yield: forall<e,a,b,c> (clause : ((resume-result<c,b>) -> e b) -> e b, cont : (() -> c) -> e a) -> yld<e,a,b><bb: V>(clause : (resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> ee: E rr: V) -> ee: E rr: V, cont : (() -> bstd/core/types/total: E) -> ee: E aa: V)

extern guardstd/core/hnd/guard: forall<e> (w : evv<e>) -> e ()(ww: evv<$3046> : evvstd/core/hnd/evv: E -> V<ee: E> ) : ee: E (std/core/types/unit: V)std/core/types/unit: V
  c  inline "kk_evv_guard(#1,kk_context())"
  js "_guard"

extern resume-finalstd/core/hnd/resume-final: forall<a> () -> a() : astd/core/types/total: E
  c  inline "kk_fatal_resume_final(kk_context())"
  js "_throw_resume_final"

fun promptstd/core/hnd/prompt: forall<a,e,b,c> (w0 : evv<e>, w1 : evv<e>, ev : ev<b>, m : marker<e,c>, ret : (a) -> e c, result : a) -> e c( w0w0: evv<$3082> : evvstd/core/hnd/evv: E -> V<e0e0: E>,  w1w1: evv<$3082> : evvstd/core/hnd/evv: E -> V<e0e0: E>, evev: ev<$3083> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, mm: marker<$3082,$3084> : markerstd/core/hnd/marker: (E, V) -> V<e0e0: E,rr: V>, retret: ($3081) -> $3082 $3084: aa: V -> e0e0: E rr: V, resultresult: $3081 : aa: V )result: -> 3483 3485 : e0e0: E rr: V
  guardstd/core/hnd/guard: (w : evv<$3082>) -> $3082 ()(w1w1: evv<$3082>)
  evv-setstd/core/hnd/evv-set: (w : evv<$3082>) -> $3082 ()(w0w0: evv<$3082>)  // restore the previous evidence vector
  match yield-promptstd/core/hnd/yield-prompt: (m : marker<$3082,$3084>) -> $3082 yld<$3082,$3081,$3084>(mm: marker<$3082,$3084>)
    Purestd/core/hnd/Pure: forall<e,a,b> yld<e,a,b> ->
      // returning
      retret: ($3081) -> $3082 $3084(resultresult: $3081)
    YieldingFinalstd/core/hnd/YieldingFinal: forall<e,a,b> yld<e,a,b> ->
      // yielding final (exception), keep yielding
      keep-yielding-finalstd/core/hnd/keep-yielding-final: () -> $3082 $3084()
    Yieldingstd/core/hnd/Yielding: forall<e,a,b> yld<e,a,b> ->
      // regular yield, install a continuation
      yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $3082 $3081, a) -> $3082 $3084) -> $3082 $3084 fnfn: forall<a> (cont : (a) -> $3082 $3081, res : a) -> $3082 $3084(contcont: ($3167) -> $3082 $3081,resres: $3167)
        // we resume, continue under a fresh a prompt again
        val w0'w0': evv<$3082> = evv-getstd/core/hnd/evv-get: () -> $3082 evv<$3082>()  // if not using scoped resumptions, w0' may be different from w0
        val w1'w1': evv<$3082> = if (evv-eqstd/core/hnd/evv-eq: (evv0 : evv<$3082>, evv1 : evv<$3082>) -> $3082 bool(w0w0: evv<$3082>,w0'w0': evv<$3082>)) then w1w1: evv<$3082> else evv-insertstd/core/hnd/evv-insert: (evv : evv<$3082>, ev : ev<$3083>) -> $3082 evv<$3082>(w0'w0': evv<$3082>,evev: ev<$3083>)
        evv-setstd/core/hnd/evv-set: (w : evv<$3082>) -> $3082 ()(w1'w1': evv<$3082>)
        promptstd/core/hnd/prompt: (w0 : evv<$3082>, w1 : evv<$3082>, ev : ev<$3083>, m : marker<$3082,$3084>, ret : ($3081) -> $3082 $3084, result : $3081) -> $3082 $3084(w0'w0': evv<$3082>,w1'w1': evv<$3082>,evev: ev<$3083>,pretend-decreasingstd/core/undiv/pretend-decreasing: (x : marker<$3082,$3084>) -> $3082 marker<$3082,$3084>(mm: marker<$3082,$3084>),retret: ($3081) -> $3082 $3084,contcont: ($3167) -> $3082 $3081(resres: $3167));
    Yieldstd/core/hnd/Yield: forall<e,a,b,c> (clause : ((resume-result<c,b>) -> e b) -> e b, cont : (() -> c) -> e a) -> yld<e,a,b>(clauseclause: ((resume-result<$3248,$3084>) -> $3082 $3084) -> $3082 $3084,contcont: (() -> $3248) -> $3082 $3081) ->
      // yielded to the operation `clause` in our handler
      fun resumeresume: (r : resume-result<$3248,$3084>) -> $3082 $3084(rr: resume-result<$3248,$3084>)result: -> $3082 $3084
        match(rr: resume-result<$3248,$3084>)
          Deepstd/core/hnd/Deep: forall<a,b> (result : a) -> resume-result<a,b>(xx: $3248) ->
            val w0'w0': evv<$3082> = evv-getstd/core/hnd/evv-get: () -> $3082 evv<$3082>()  // if not using scoped resumptions, w0' may be different from w0
            val w1'w1': evv<$3082> = if evv-eqstd/core/hnd/evv-eq: (evv0 : evv<$3082>, evv1 : evv<$3082>) -> $3082 bool(w0w0: evv<$3082>,w0'w0': evv<$3082>) then w1w1: evv<$3082> else evv-insertstd/core/hnd/evv-insert: (evv : evv<$3082>, ev : ev<$3083>) -> $3082 evv<$3082>(w0'w0': evv<$3082>,evev: ev<$3083>)
            evv-setstd/core/hnd/evv-set: (w : evv<$3082>) -> $3082 ()(w1'w1': evv<$3082>)
            promptstd/core/hnd/prompt: (w0 : evv<$3082>, w1 : evv<$3082>, ev : ev<$3083>, m : marker<$3082,$3084>, ret : ($3081) -> $3082 $3084, result : $3081) -> $3082 $3084(w0'w0': evv<$3082>,w1'w1': evv<$3082>,evev: ev<$3083>,pretend-decreasingstd/core/undiv/pretend-decreasing: (x : marker<$3082,$3084>) -> $3082 marker<$3082,$3084>(mm: marker<$3082,$3084>),retret: ($3081) -> $3082 $3084,contcont: (() -> $3248) -> $3082 $3081({xx: $3248}))
          Shallowstd/core/hnd/Shallow: forall<a,b> (result : a) -> resume-result<a,b>(xx: $3248) ->
            yield-bindstd/core/hnd/yield-bind: (x : $3081, next : ($3081) -> $3082 $3084) -> $3082 $3084( contcont: (() -> $3248) -> $3082 $3081({xx: $3248}), fnfn: (y : $3081) -> $3082 $3084(yy: $3081) retret: ($3081) -> $3082 $3084(yy: $3081) )
          Finalizestd/core/hnd/Finalize: forall<a,b> (result : b) -> resume-result<a,b>(xx: $3084) ->
            val w0'w0': evv<$3082> = evv-getstd/core/hnd/evv-get: () -> $3082 evv<$3082>()  // if not using scoped resumptions, w0' may be different from w0
            val w1'w1': evv<$3082> = if evv-eqstd/core/hnd/evv-eq: (evv0 : evv<$3082>, evv1 : evv<$3082>) -> $3082 bool(w0w0: evv<$3082>,w0'w0': evv<$3082>) then w1w1: evv<$3082> else evv-insertstd/core/hnd/evv-insert: (evv : evv<$3082>, ev : ev<$3083>) -> $3082 evv<$3082>(w0'w0': evv<$3082>,evev: ev<$3083>)
            evv-setstd/core/hnd/evv-set: (w : evv<$3082>) -> $3082 ()(w1'w1': evv<$3082>)
            promptstd/core/hnd/prompt: (w0 : evv<$3082>, w1 : evv<$3082>, ev : ev<$3083>, m : marker<$3082,$3084>, ret : ($3081) -> $3082 $3084, result : $3081) -> $3082 $3084(w0'w0': evv<$3082>,w1'w1': evv<$3082>,evev: ev<$3083>,pretend-decreasingstd/core/undiv/pretend-decreasing: (x : marker<$3082,$3084>) -> $3082 marker<$3082,$3084>(mm: marker<$3082,$3084>),retret: ($3081) -> $3082 $3084,contcont: (() -> $3248) -> $3082 $3081({ yield-to-finalstd/core/hnd/yield-to-final: (m : marker<$3082,$3084>, clause : ((resume-result<$3248,$3084>) -> $3082 $3084) -> $3082 $3084) -> $3248(mm: marker<$3082,$3084>, fnfn: ((resume-result<$3248,$3084>) -> $3082 $3084) -> $3082 $3084(_k) xx: $3084) }))
      clauseclause: ((resume-result<$3248,$3084>) -> $3082 $3084) -> $3082 $3084(resumeresume: (r : resume-result<$3248,$3084>) -> $3082 $3084) // TODO: we should exit prompt first, and then execute clause to use constant stack space when resuming

pub noinline fun @hhandle( tagtag: htag<$3501>:htagstd/core/hnd/htag: ((E, V) -> V) -> V<hh: (E, V) -> V>, hh: $3501<$3499,$3502> : hh: (E, V) -> V<ee: E,rr: V>, retret: ($3498) -> $3499 $3502: aa: V -> ee: E rr: V, actionaction: () -> $3500 $3498 : () -> e1e1: E aa: V )result: -> 3613 3616 : ee: E rr: V
  // insert new evidence for our handler
  val w0w0: evv<$3499> = evv-getstd/core/hnd/evv-get: () -> $3499 evv<$3499>()
  val mm: marker<$3499,$3502>  = fresh-markerstd/core/hnd/fresh-marker: () -> $3499 marker<$3499,$3502>()
  val evev: ev<$3501> = Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(tagtag: htag<$3501>,mm: marker<$3499,$3502>,hh: $3501<$3499,$3502>,w0w0: evv<$3499>)
  val w1w1: evv<$3499> = evv-insertstd/core/hnd/evv-insert: (evv : evv<$3499>, ev : ev<$3501>) -> $3499 evv<$3499>(w0w0: evv<$3499>,evev: ev<$3501>)
  evv-setstd/core/hnd/evv-set: (w : evv<$3499>) -> $3499 ()(w1w1: evv<$3499>)
  // call action first (this may be yielding), then check the result
  promptstd/core/hnd/prompt: (w0 : evv<$3499>, w1 : evv<$3499>, ev : ev<$3501>, m : marker<$3499,$3502>, ret : ($3498) -> $3499 $3502, result : $3498) -> $3499 $3502(w0w0: evv<$3499>,w1w1: evv<$3499>,evev: ev<$3501>,mm: marker<$3499,$3502>,retret: ($3498) -> $3499 $3502,cast-ev0std/core/hnd/cast-ev0: (f : () -> $3500 $3498) -> $3499 (() -> $3499 $3498)(actionaction: () -> $3500 $3498)())

// -------------------------------------------
// named handler
// (which is not inserted into the evidence vector)
// -------------------------------------------

pub noinline fun @named-handle( tagtag: htag<$3635>:htagstd/core/hnd/htag: ((E, V) -> V) -> V<hh: (E, V) -> V>, hh: $3635<$3633,$3636> : hh: (E, V) -> V<ee: E,rr: V>, retret: ($3632) -> $3633 $3636: aa: V -> ee: E rr: V, actionaction: (ev<$3635>) -> $3634 $3632 : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V> -> e1e1: E aa: V )result: -> 3729 3732 : ee: E rr: V
  val mm: marker<$3633,$3636> = fresh-marker-namedstd/core/hnd/fresh-marker-named: () -> $3633 marker<$3633,$3636>()            // unique (negative) marker, but never gets inserted into the evidence vector
  val w0w0: evv<$3633> = evv-getstd/core/hnd/evv-get: () -> $3633 evv<$3633>()
  val evev: ev<$3635> = Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(tagtag: htag<$3635>,mm: marker<$3633,$3636>,hh: $3635<$3633,$3636>,w0w0: evv<$3633>)
  promptstd/core/hnd/prompt: (w0 : evv<$3633>, w1 : evv<$3633>, ev : ev<$3635>, m : marker<$3633,$3636>, ret : ($3632) -> $3633 $3636, result : $3632) -> $3633 $3636(w0w0: evv<$3633>,w0w0: evv<$3633>,evev: ev<$3635>,mm: marker<$3633,$3636>,retret: ($3632) -> $3633 $3636,cast-ev1std/core/hnd/cast-ev1: (f : (ev<$3635>) -> $3634 $3632) -> $3633 ((ev<$3635>) -> $3633 $3632)(actionaction: (ev<$3635>) -> $3634 $3632)(evev: ev<$3635>))


// -------------------------------------------
// mask
// -------------------------------------------

fun mask-at1std/core/hnd/mask-at1: forall<a,b,e,e1> (i : ev-index, behind : bool, action : (a) -> e b, x : a) -> e1 b( ii: ev-index : ev-indexstd/core/hnd/ev-index: V, behindbehind: bool : boolstd/core/types/bool: V, actionaction: ($3748) -> $3750 $3749 : (aa: V) -> e1e1: E bb: V, xx: $3748 : aa: V )result: -> 3864 3862 : e2e2: E bb: V
  val w0w0: evv<_3757> = evv-swap-deletestd/core/hnd/evv-swap-delete: (i : ev-index, behind : bool) -> $3751 evv<_3757>(ii: ev-index,behindbehind: bool)
  val yy: $3749 = cast-ev1std/core/hnd/cast-ev1: (f : ($3748) -> $3750 $3749) -> $3751 (($3748) -> $3751 $3749)(actionaction: ($3748) -> $3750 $3749)(xx: $3748)
  evv-setstd/core/hnd/evv-set: (w : evv<_3757>) -> $3751 ()(w0w0: evv<_3757>)
  if yieldingstd/core/hnd/yielding: () -> $3751 bool() returnreturn: $3749 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $3751 $3749, a) -> $3751 $3749) -> $3751 $3749( fnfn: forall<a> (cont : (a) -> $3751 $3749, res : a) -> $3751 $3749(contcont: ($3807) -> $3751 $3749,resres: $3807) mask-at1std/core/hnd/mask-at1: (i : ev-index, behind : bool, action : ($3807) -> $3751 $3749, x : $3807) -> $3751 $3749(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : ev-index) -> $3751 ev-index(ii: ev-index),behindbehind: bool,contcont: ($3807) -> $3751 $3749,resres: $3807) )std/core/types/Unit: ()
  yy: $3749

pub fun @mask-at<aa: V,e1e1: E,e2e2: E>( ii: ev-index : ev-indexstd/core/hnd/ev-index: V, behindbehind: bool : boolstd/core/types/bool: V, actionaction: () -> $3878 $3877 : () -> e1e1: E aa: V )result: -> 3976 3974 : e2e2: E aa: V
  val w0w0: evv<_3885> = evv-swap-deletestd/core/hnd/evv-swap-delete: (i : ev-index, behind : bool) -> $3879 evv<_3885>(ii: ev-index,behindbehind: bool)
  val xx: $3877 = cast-ev0std/core/hnd/cast-ev0: (f : () -> $3878 $3877) -> $3879 (() -> $3879 $3877)(actionaction: () -> $3878 $3877)()
  evv-setstd/core/hnd/evv-set: (w : evv<_3885>) -> $3879 ()(w0w0: evv<_3885>)
  if yieldingstd/core/hnd/yielding: () -> $3879 bool() returnreturn: $3877 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $3879 $3877, a) -> $3879 $3877) -> $3879 $3877( fnfn: forall<a> (cont : (a) -> $3879 $3877, res : a) -> $3879 $3877(contcont: ($3931) -> $3879 $3877,resres: $3931) mask-at1std/core/hnd/mask-at1: (i : ev-index, behind : bool, action : ($3931) -> $3879 $3877, x : $3931) -> $3879 $3877(ii: ev-index,behindbehind: bool,contcont: ($3931) -> $3879 $3877,resres: $3931) )std/core/types/Unit: ()
  xx: $3877

// mask for builtin effects without a handler or evidence (like `:st` or `:local`)
pub fun @mask-builtin<aa: V,e1e1: E,e2e2: E>( actionaction: () -> $3987 $3986 : () -> e1e1: E aa: V )result: -> 4019 4017 : e2e2: E aa: V
  cast-ev0std/core/hnd/cast-ev0: (f : () -> $3987 $3986) -> $3988 (() -> $3988 $3986)(actionaction: () -> $3987 $3986)()


// -------------------------------------------
// Local variables
// -------------------------------------------

fun prompt-local-varstd/core/hnd/prompt-local-var: forall<a,b,h> (loc : local-var<h,a>, res : b) -> <div,local<h>> b<aa: V,bb: V,ss: H,ee: E>(locloc: local-var<$4031,$4029>:local-varstd/core/types/local-var: (H, V) -> V<ss: H,aa: V>, resres: $4030 : bb: V  )result: -> <div,local<4141>|4142> 4140 : <divstd/core/types/div: X,localstd/core/types/local: H -> X<ss: H>|std/core/types/effect-extend: (X, E) -> Eee: E> bb: V
  if !std/core/types/bool/(!): (b : bool) -> <div,local<$4031>|$4032> boolyieldingstd/core/hnd/yielding: () -> <div,local<$4031>|$4032> bool() returnreturn: $4030 resres: $4030;
  val vv: $4029 = locloc: $4029
?hdiv=iev@4057
yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> <div,local<$4031>|$4032> $4030, a) -> <div,local<$4031>|$4032> $4030) -> <div,local<$4031>|$4032> $4030(fnfn: forall<a> (cont : (a) -> <div,local<$4031>|$4032> $4030, x : a) -> <div,local<$4031>|$4032> $4030(contcont: ($4080) -> <div,local<$4031>|$4032> $4030,xx: $4080){ locloc: local-var<$4031,$4029> :=std/core/types/local-set: (v : local-var<$4031,$4029>, assigned : $4029) -> <local<$4031>,div|$4032> () vv: $4029; prompt-local-varstd/core/hnd/prompt-local-var: (loc : local-var<$4031,$4029>, res : $4030) -> <div,local<$4031>|$4032> $4030(@byref(locloc: local-var<$4031,$4029>),contcont: ($4080) -> <div,local<$4031>|$4032> $4030(xx: $4080)) }
) // restore state early before the resume pub inline fun local-varstd/core/hnd/local-var: forall<a,b,e,h> (init : a, action : (local-var<h,a>) -> <local<h>|e> b) -> <local<h>|e> b(initinit: $4176:aa: V, actionaction: (local-var<$4179,$4176>) -> <local<$4179>|$4178> $4177: (@local-var:local-varstd/core/types/local-var: (H, V) -> V<ss: H,aa: V>) -> <localstd/core/types/local: H -> X<ss: H>|std/core/types/effect-extend: (X, E) -> Eee: E> bb: V )result: -> <local<4257>|4256> 4255 : <localstd/core/types/local: H -> X<ss: H>|std/core/types/effect-extend: (X, E) -> Eee: E> bb: V pretend-no-divstd/core/undiv/pretend-no-div: (action : () -> <div,local<$4179>|$4178> $4177) -> <local<$4179>|$4178> $4177 val locloc: local-var<$4179,$4176> : local-varstd/core/types/local-var: (H, V) -> V<__w-l468-c25: H,__w-l468-c27: V> = local-newstd/core/types/local-new: (value : $4176) -> <local<$4179>,div|$4178> local-var<$4179,$4176>(initinit: $4176) val resres: $4177 = cast-ev1std/core/hnd/cast-ev1: (f : (local-var<$4179,$4176>) -> <local<$4179>|$4178> $4177) -> <div,local<$4179>|$4178> ((local-var<$4179,$4176>) -> <div,local<$4179>|$4178> $4177)(actionaction: (local-var<$4179,$4176>) -> <local<$4179>|$4178> $4177)(@byref(locloc: local-var<$4179,$4176>)) prompt-local-varstd/core/hnd/prompt-local-var: (loc : local-var<$4179,$4176>, res : $4177) -> <div,local<$4179>|$4178> $4177(@byref(locloc: local-var<$4179,$4176>),resres: $4177) // ------------------------------------------- // Finally // ------------------------------------------- pub fun finallystd/core/hnd/finally: forall<a,e> (fin : () -> e (), action : () -> e a) -> e a( finfin: () -> $4423 () : () -> ee: E (std/core/types/unit: V)std/core/types/unit: V, actionaction: () -> $4423 $4422 : () -> ee: E aa: V )result: -> 4445 4444 : ee: E aa: V finally-promptstd/core/hnd/finally-prompt: (fin : () -> $4423 (), res : $4422) -> $4423 $4422(finfin: () -> $4423 (), actionaction: () -> $4423 $4422()); fun finally-promptstd/core/hnd/finally-prompt: forall<a,e> (fin : () -> e (), res : a) -> e a(finfin: () -> $4271 () : () -> ee: E (std/core/types/unit: V)std/core/types/unit: V, resres: $4270 : aa: V )result: -> 4415 4414 : ee: E aa: V if !std/core/types/bool/(!): (b : bool) -> $4271 boolyieldingstd/core/hnd/yielding: () -> $4271 bool() then finfin: () -> $4271 ()() if yieldingstd/core/hnd/yielding: () -> $4271 bool() then yield-extendstd/core/hnd/yield-extend: (next : (_4302) -> $4271 $4270) -> $4271 $4270(fnfn: (_4302) -> $4271 $4270(_) resres: $4270) else resres: $4270 elif yielding-non-finalstd/core/hnd/yielding-non-final: () -> $4271 bool() then yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $4271 $4270, a) -> $4271 $4270) -> $4271 $4270(fnfn: forall<a> (cont : (a) -> $4271 $4270, x : a) -> $4271 $4270(contcont: ($4329) -> $4271 $4270,xx: $4329){ finally-promptstd/core/hnd/finally-prompt: (fin : () -> $4271 (), res : $4270) -> $4271 $4270(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : () -> $4271 ()) -> $4271 (() -> $4271 ())(finfin: () -> $4271 ()),contcont: ($4329) -> $4271 $4270(xx: $4329)) }) else val yldyld: yield-info = yield-capturestd/core/hnd/yield-capture: () -> $4271 yield-info() finfin: () -> $4271 ()() if yieldingstd/core/hnd/yielding: () -> $4271 bool() returnreturn: $4270 yield-extendstd/core/hnd/yield-extend: (next : (_4375) -> $4271 $4270) -> $4271 $4270( fnfn: (_4375) -> $4271 $4270(_x) unsafe-reyieldstd/core/hnd/unsafe-reyield: (yld : yield-info) -> $4271 $4270(yldyld: yield-info) )std/core/types/Unit: () unsafe-reyieldstd/core/hnd/unsafe-reyield: (yld : yield-info) -> $4271 $4270(yldyld: yield-info) /* fun finalize(cont : (() -> b) -> e r, res : a) : e a val m : marker<_e,_r> = fresh-marker() val w = evv-get() prompt(w,w,ev-none(),m,id, yield-bind( cont({ yield-to-final(m,fn(_k) res) }), fn(_x) res )) // TODO: special prompt that does not insert on resume? */ // ------------------------------------------- // Initially // ------------------------------------------- // add integers inline extern addstd/core/hnd/add: (i : int, j : int) -> int(i : intstd/core/types/int: V, j : intstd/core/types/int: V) : intstd/core/types/int: V c "kk_integer_add" cs inline "(#1 + #2)" js inline "(#1 + #2)" // "$std_core_types._int_add" // are two integers equal? inline extern eqstd/core/hnd/eq: (x : int, y : int) -> bool( ^x : intstd/core/types/int: V, ^y : intstd/core/types/int: V) : boolstd/core/types/bool: V c "kk_integer_eq_borrow" cs inline "(#1 == #2)" js inline "(#1 == #2)" // $std_core_types._int_eq" pub fun initiallystd/core/hnd/initially: forall<a,e> (init : (int) -> e (), action : () -> e a) -> e a(initinit: (int) -> $4658 () : (intstd/core/types/int: V) -> ee: E (std/core/types/unit: V)std/core/types/unit: V, actionaction: () -> $4658 $4657 : () -> ee: E aa: V )result: -> 4715 4714 : ee: E aa: V initinit: (int) -> $4658 ()(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
) if yieldingstd/core/hnd/yielding: () -> $4658 bool() returnreturn: $4657 yield-extendstd/core/hnd/yield-extend: (next : (()) -> $4658 $4657) -> $4658 $4657(fnfn: (()) -> $4658 $4657(_ret:(std/core/types/unit: V)std/core/types/unit: V) initially-promptstd/core/hnd/initially-prompt: (init : (int) -> $4658 (), res : $4657) -> $4658 $4657(initinit: (int) -> $4658 (),actionaction: () -> $4658 $4657()) )std/core/types/Unit: () initially-promptstd/core/hnd/initially-prompt: (init : (int) -> $4658 (), res : $4657) -> $4658 $4657(initinit: (int) -> $4658 (), actionaction: () -> $4658 $4657()
) fun initially-promptstd/core/hnd/initially-prompt: forall<a,e> (init : (int) -> e (), res : a) -> e a( initinit: (int) -> $4453 () : (intstd/core/types/int: V) -> ee: E (std/core/types/unit: V)std/core/types/unit: V, resres: $4452 : aa: V )result: -> 4650 4649 : ee: E aa: V if yielding-non-finalstd/core/hnd/yielding-non-final: () -> $4453 bool() then val countcount: ref<global,int> = unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$4453> ref<global,int>) -> $4453 (() -> $4453 ref<global,int>){refstd/core/types/ref: (value : int) -> <alloc<global>,read<global>,write<global>|$4453> ref<global,int>(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
)}() yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $4453 $4452, a) -> $4453 $4452) -> $4453 $4452(fnfn: forall<a> (cont : (a) -> $4453 $4452, x : a) -> $4453 $4452(contcont: ($4495) -> $4453 $4452,xx: $4495) val cntcnt: int = unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$4453> int) -> $4453 (() -> $4453 int){ !std/core/types/ref/(!): (ref : ref<global,int>, @implicit/hdiv : hdiv<global,int,<alloc<global>,write<global>|$4453>>) -> <read<global>,alloc<global>,write<global>|$4453> int
?hdiv=iev@4514
countcount: ref<global,int> }() // increase counter on every resumption unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$4453> ()) -> $4453 (() -> $4453 ()){ countcount: ref<global,int> :=std/core/types/set: (ref : ref<global,int>, assigned : int) -> <write<global>,alloc<global>,read<global>|$4453> () addstd/core/hnd/add: (i : int, j : int) -> <write<global>,alloc<global>,read<global>|$4453> int(cntcnt: int,1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
) }() if eqstd/core/hnd/eq: (x : int, y : int) -> $4453 bool(cntcnt: int,0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
) then (std/core/types/Unit: ())std/core/types/Unit: () else // for every resume after the first, run the initializer val rr: () = initinit: (int) -> $4453 ()(cntcnt: int) if yieldingstd/core/hnd/yielding: () -> $4453 bool() then { yield-extendstd/core/hnd/yield-extend: (next : (_4583) -> $4453 $4452) -> $4453 $4452( fnfn: (_4583) -> $4453 $4452(_ret) initially-promptstd/core/hnd/initially-prompt: (init : (int) -> $4453 (), res : $4452) -> $4453 $4452(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : (int) -> $4453 ()) -> $4453 ((int) -> $4453 ())(initinit: (int) -> $4453 ()), contcont: ($4495) -> $4453 $4452(xx: $4495)) ); (std/core/types/Unit: ())std/core/types/Unit: () }std/core/types/Unit: () initially-promptstd/core/hnd/initially-prompt: (init : (int) -> $4453 (), res : $4452) -> $4453 $4452(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : (int) -> $4453 ()) -> $4453 ((int) -> $4453 ())(initinit: (int) -> $4453 ()), contcont: ($4495) -> $4453 $4452(xx: $4495)) ) else resres: $4452
// ------------------------------------------- // Resume context // ------------------------------------------- abstract value struct resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E::E,e0e0: E::E,rr: V>( kresult: -> total (resume-result<4757,4760>) -> 4758 4760 : resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> ee: E rr: V ) pub fun resumestd/core/hnd/resume: forall<a,e,e1,b> (r : resume-context<a,e,e1,b>, x : a) -> e b( rr: resume-context<$4850,$4851,$4852,$4853> : resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E,e0e0: E,rr: V>, xx: $4850 : bb: V )result: -> 4901 4903 : ee: E rr: V (rr: resume-context<$4850,$4851,$4852,$4853>.kstd/core/hnd/resume-context/k: (resume-context<$4850,$4851,$4852,$4853>) -> $4851 ((resume-result<$4850,$4853>) -> $4851 $4853))(Deepstd/core/hnd/Deep: forall<a,b> (result : a) -> resume-result<a,b>(xx: $4850)) pub fun resume-shallowstd/core/hnd/resume-shallow: forall<a,e,e1,b> (r : resume-context<a,e,e1,b>, x : a) -> e1 b( rr: resume-context<$4916,$4917,$4918,$4919> : resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E,e0e0: E,rr: V>, xx: $4916 : bb: V )result: -> 4984 4985 : e0e0: E rr: V cast-ev1std/core/hnd/cast-ev1: (f : (resume-result<$4916,$4919>) -> $4917 $4919) -> $4918 ((resume-result<$4916,$4919>) -> $4918 $4919)(rr: resume-context<$4916,$4917,$4918,$4919>.kstd/core/hnd/resume-context/k: (resume-context<$4916,$4917,$4918,$4919>) -> $4918 ((resume-result<$4916,$4919>) -> $4917 $4919))(Shallowstd/core/hnd/Shallow: forall<a,b> (result : a) -> resume-result<a,b>(xx: $4916)) pub fun finalizestd/core/hnd/finalize: forall<a,e,e1,b> (r : resume-context<a,e,e1,b>, x : b) -> e b( rr: resume-context<$4998,$4999,$5000,$5001> : resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E,e0e0: E,rr: V>, xx: $5001 : rr: V )result: -> 5049 5051 : ee: E rr: V //finalize(r.k,x) (rr: resume-context<$4998,$4999,$5000,$5001>.kstd/core/hnd/resume-context/k: (resume-context<$4998,$4999,$5000,$5001>) -> $4999 ((resume-result<$4998,$5001>) -> $4999 $5001))(Finalizestd/core/hnd/Finalize: forall<a,b> (result : b) -> resume-result<a,b>(xx: $5001)) // ------------------------------------------- // Clauses // ------------------------------------------- abstract value type clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V::V,bb: V::V,hh: (E, V) -> V::(E,V)->V,ee: E::E,rr: V::V> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>( clausestd/core/hnd/clause1/clause: forall<a,b,c,e,d> (clause1 : clause1<a,b,c,e,d>) -> ((marker<e,d>, ev<c>, a) -> e b): (markerstd/core/hnd/marker: (E, V) -> V<ee: E,rr: V>, evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, aa: V) -> ee: E bb: V ) inline extern cast-clause0std/core/hnd/cast-clause0: forall<a,e,e1,b,c> (f : (marker<e1,c>, ev<b>) -> e1 a) -> e ((marker<e1,c>, ev<b>) -> e a)( f : (markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>,evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>) -> e1e1: E bb: V) : ee: E ((markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>,evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>) -> ee: E bb: V) inline "#1" inline extern cast-clause1std/core/hnd/cast-clause1: forall<a,b,e,e1,c,d> (f : (marker<e1,d>, ev<c>, a) -> e1 b) -> e ((marker<e1,d>, ev<c>, a) -> e b)( f : (markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>,evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>,aa: V) -> e1e1: E bb: V) : ee: E ((markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>,evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>,aa: V) -> ee: E bb: V) inline "#1" inline extern cast-clause2std/core/hnd/cast-clause2: forall<a,b,c,e,e1,d,a1> (f : (marker<e1,a1>, ev<d>, a, b) -> e1 c) -> e ((marker<e1,a1>, ev<d>, a, b) -> e c)( f : (markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>,evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>,a1a1: V,a2a2: V) -> e1e1: E bb: V) : ee: E ((markerstd/core/hnd/marker: (E, V) -> V<e1e1: E,rr: V>,evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>,a1a1: V,a2a2: V) -> ee: E bb: V) inline "#1" pub inline fun @perform1<aa: V,bb: V,hh: (E, V) -> V>( evev: ev<$5220> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: forall<e,a> ($5220<e,a>) -> clause1<$5218,$5219,$5220,e,a> : (forall<e1e1: E,rr: V> hh: (E, V) -> V<e1e1: E,rr: V> -> clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,hh: (E, V) -> V,e1e1: E,rr: V>), xx: $5218 : aa: V )result: -> 5309 5307 : ee: E bb: V match evev: ev<$5220> Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(_tag,mm: marker<$5227,$5228>,hh: $5220<$5227,$5228>,_w) -> match hh: $5220<$5227,$5228>.opop: ($5220<$5227,$5228>) -> $5221 clause1<$5218,$5219,$5220,$5227,$5228> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>(ff: (marker<$5227,$5228>, ev<$5220>, $5218) -> $5227 $5219) -> cast-clause1std/core/hnd/cast-clause1: (f : (marker<$5227,$5228>, ev<$5220>, $5218) -> $5227 $5219) -> $5221 ((marker<$5227,$5228>, ev<$5220>, $5218) -> $5221 $5219)(ff: (marker<$5227,$5228>, ev<$5220>, $5218) -> $5227 $5219)(mm: marker<$5227,$5228>,evev: ev<$5220>,xx: $5218) fun evv-swap-withstd/core/hnd/evv-swap-with: forall<a,e> (ev : ev<a>) -> evv<e>(evev: ev<$5324> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>)result: -> total evv<5365> match(evev: ev<$5324>) Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(_tag,_m,_h,ww: evv<$5330>) -> evv-swapstd/core/hnd/evv-swap: (w : evv<$5330>) -> evv<_5347>(ww: evv<$5330>) inline fun under1std/core/hnd/under1: forall<a,b,e,c> (ev : ev<c>, op : (a) -> e b, x : a) -> e b( evev: ev<$5489> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: ($5486) -> $5488 $5487 : aa: V -> ee: E bb: V, xx: $5486 : aa: V )result: -> 5585 5584 : ee: E bb: V val w0w0: evv<_5497> = evv-swap-withstd/core/hnd/evv-swap-with: (ev : ev<$5489>) -> $5488 evv<_5497>(evev: ev<$5489>) val yy: $5487 = opop: ($5486) -> $5488 $5487(xx: $5486) // evv-set(w0) // only needed before yielding for evidence expected check in prompt if yieldingstd/core/hnd/yielding: () -> $5488 bool() returnreturn: $5487 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $5488 $5487, a) -> $5488 $5487) -> $5488 $5487( fnfn: forall<a> (cont : (a) -> $5488 $5487, res : a) -> $5488 $5487(contcont: ($5521) -> $5488 $5487,resres: $5521) under1xstd/core/hnd/under1x: (ev : ev<$5489>, op : ($5521) -> $5488 $5487, x : $5521) -> $5488 $5487(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : ev<$5489>) -> $5488 ev<$5489>(evev: ev<$5489>),contcont: ($5521) -> $5488 $5487,resres: $5521) )std/core/types/Unit: () evv-setstd/core/hnd/evv-set: (w : evv<_5497>) -> $5488 ()(w0w0: evv<_5497>) yy: $5487 // extra under1x to make under1 inlineable noinline fun under1xstd/core/hnd/under1x: forall<a,b,e,c> (ev : ev<c>, op : (a) -> e b, x : a) -> e b( evev: ev<$5376> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: ($5373) -> $5375 $5374 : aa: V -> ee: E bb: V, xx: $5373 : aa: V )result: -> 5472 5471 : ee: E bb: V val w0w0: evv<_5384> = evv-swap-withstd/core/hnd/evv-swap-with: (ev : ev<$5376>) -> $5375 evv<_5384>(evev: ev<$5376>) val yy: $5374 = opop: ($5373) -> $5375 $5374(xx: $5373) // evv-set(w0) // only needed before yielding for evidence expected check in prompt if yieldingstd/core/hnd/yielding: () -> $5375 bool() returnreturn: $5374 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $5375 $5374, a) -> $5375 $5374) -> $5375 $5374( fnfn: forall<a> (cont : (a) -> $5375 $5374, res : a) -> $5375 $5374(contcont: ($5408) -> $5375 $5374,resres: $5408) under1xstd/core/hnd/under1x: (ev : ev<$5376>, op : ($5408) -> $5375 $5374, x : $5408) -> $5375 $5374(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : ev<$5376>) -> $5375 ev<$5376>(evev: ev<$5376>),contcont: ($5408) -> $5375 $5374,resres: $5408) )std/core/types/Unit: () evv-setstd/core/hnd/evv-set: (w : evv<_5384>) -> $5375 ()(w0w0: evv<_5384>) yy: $5374 pub fun clause-control-raw1std/core/hnd/clause-control-raw1: forall<a,b,e,e1,c,d> (op : (x : a, r : resume-context<b,e,e1,d>) -> e d) -> clause1<a,b,c,e,d>( opop: (x : $5599, r : resume-context<$5600,$5601,$5602,$5604>) -> $5601 $5604 : (x:aa: V, r: resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E,e0e0: E,rr: V>) -> ee: E rr: V )result: -> total clause1<5684,5685,5688,5686,5689> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>(fnfn: (m : marker<$5601,$5604>, ev<$5603>, x : $5599) -> $5601 $5600(mm: marker<$5601,$5604>,_ev,xx: $5599){ yield-tostd/core/hnd/yield-to: (m : marker<$5601,$5604>, clause : ((resume-result<$5600,$5604>) -> $5601 $5604) -> $5601 $5604) -> $5601 $5600(mm: marker<$5601,$5604>, fnfn: (k : (resume-result<$5600,$5604>) -> $5601 $5604) -> $5601 $5604(kk: (resume-result<$5600,$5604>) -> $5601 $5604){ opop: (x : $5599, r : resume-context<$5600,$5601,$5602,$5604>) -> $5601 $5604(xx: $5599,Resume-contextstd/core/hnd/Resume-context: forall<a,e,e1,b> (k : (resume-result<a,b>) -> e b) -> resume-context<a,e,e1,b>(kk: (resume-result<$5600,$5604>) -> $5601 $5604)) } ) } ) fun getstd/core/hnd/get: forall<a,h> (ref : ref<h,a>) -> <read<h>,div> a( refref: ref<$5710,$5709>: refstd/core/types/ref: (H, V) -> V<hh: H,aa: V>)result: -> <read<5738>,div> 5737 : <std/core/types/total: Ereadstd/core/types/read: H -> X<hh: H>,divstd/core/types/div: X> aa: V !std/core/types/ref/(!): (ref : ref<$5710,$5709>, @implicit/hdiv : hdiv<$5710,$5709,div>) -> <read<$5710>,div> $5709
?hdiv=iev@5714
refref: ref<$5710,$5709>
inline extern unsafe-ststd/core/hnd/unsafe-st: forall<a,e> (f : () -> <st<global>|e> a) -> (() -> e a)(f : () -> <ststd/core/types/st: H -> E<globalstd/core/types/global: H>|ee: E> aa: V ) : ((std/core/types/total: E) -> ee: E aa: V) inline "#1" fun protect-promptstd/core/hnd/protect-prompt: forall<a,e,b> (resumed : ref<global,bool>, k : (resume-result<a,b>) -> e b, res : b) -> e b( resumedresumed: ref<global,bool> : refstd/core/types/ref: (H, V) -> V<globalstd/core/types/global: H,boolstd/core/types/bool: V>, kk: (resume-result<$5746,$5748>) -> $5747 $5748 : resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> ee: E rr: V, resres: $5748 : rr: V )result: -> 5937 5938 : ee: E rr: V val did-resumedid-resume: bool : boolstd/core/types/bool: V = (unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$5747> bool) -> $5747 (() -> $5747 bool){ !std/core/types/ref/(!): (ref : ref<global,bool>, @implicit/hdiv : hdiv<global,bool,<alloc<global>,write<global>|$5747>>) -> <read<global>,alloc<global>,write<global>|$5747> bool
?hdiv=iev@5767
resumedresumed: ref<global,bool> })() if did-resumedid-resume: bool then // if resumed, we no longer need to protect resres: $5748 elif !std/core/types/bool/(!): (b : bool) -> $5747 boolyieldingstd/core/hnd/yielding: () -> $5747 bool() then // otherwise, if we are not yielding, resume k with finalization (to run all finally clauses) kk: (resume-result<$5746,$5748>) -> $5747 $5748(Finalizestd/core/hnd/Finalize: forall<a,b> (result : b) -> resume-result<a,b>(resres: $5748)) elif yielding-non-finalstd/core/hnd/yielding-non-final: () -> $5747 bool() then // if we yield non-final to an operation, extend the continuation with this prompt (so we keep protecting after being resumed) yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $5747 $5748, a) -> $5747 $5748) -> $5747 $5748( fnfn: forall<a> (cont : (a) -> $5747 $5748, x : a) -> $5747 $5748(contcont: ($5831) -> $5747 $5748,xx: $5831) protect-promptstd/core/hnd/protect-prompt: (resumed : ref<global,bool>, k : (resume-result<$5746,$5748>) -> $5747 $5748, res : $5748) -> $5747 $5748(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : ref<global,bool>) -> $5747 ref<global,bool>(resumedresumed: ref<global,bool>),kk: (resume-result<$5746,$5748>) -> $5747 $5748,contcont: ($5831) -> $5747 $5748(xx: $5831)) ) else // if we are in a final yield, capture it, resume k with finalization, and reyield val yldyld: yield-info = yield-capturestd/core/hnd/yield-capture: () -> $5747 yield-info() kk: (resume-result<$5746,$5748>) -> $5747 $5748(Finalizestd/core/hnd/Finalize: forall<a,b> (result : b) -> resume-result<a,b>(resres: $5748)) if yieldingstd/core/hnd/yielding: () -> $5747 bool() returnreturn: $5748 yield-extendstd/core/hnd/yield-extend: (next : (_5892) -> $5747 $5748) -> $5747 $5748( fnfn: (_5892) -> $5747 $5748(_x) unsafe-reyieldstd/core/hnd/unsafe-reyield: (yld : yield-info) -> $5747 $5748(yldyld: yield-info) )std/core/types/Unit: () // yikes, a finally clause is itself yielding... unsafe-reyieldstd/core/hnd/unsafe-reyield: (yld : yield-info) -> $5747 $5748(yldyld: yield-info
) fun protectstd/core/hnd/protect: forall<a,b,e,c> (x : a, clause : (x : a, k : (b) -> e c) -> e c, k : (resume-result<b,c>) -> e c) -> e c( xx: $5948 : aa: V, clauseclause: (x : $5948, k : ($5949) -> $5950 $5951) -> $5950 $5951 : (x:aa: V, k: bb: V -> ee: E rr: V) -> ee: E rr: V, kk: (resume-result<$5949,$5951>) -> $5950 $5951 : resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> ee: E rr: V )result: -> 6057 6058 : ee: E rr: V val resumedresumed: ref<global,bool> = (unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$5950> ref<global,bool>) -> $5950 (() -> $5950 ref<global,bool>){refstd/core/types/ref: (value : bool) -> <alloc<global>,read<global>,write<global>|$5950> ref<global,bool>(Falsestd/core/types/False: bool)})() fun kprotectkprotect: (ret : $5949) -> $5950 $5951(retret: $5949)result: -> $5950 $5951 (unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$5950> ()) -> $5950 (() -> $5950 ()){resumedresumed: ref<global,bool> :=std/core/types/set: (ref : ref<global,bool>, assigned : bool) -> <write<global>,alloc<global>,read<global>|$5950> () Truestd/core/types/True: bool})() kk: (resume-result<$5949,$5951>) -> $5950 $5951(Deepstd/core/hnd/Deep: forall<a,b> (result : a) -> resume-result<a,b>(retret: $5949)) val resres: $5951 = clauseclause: (x : $5948, k : ($5949) -> $5950 $5951) -> $5950 $5951(xx: $5948,kprotectkprotect: (ret : $5949) -> $5950 $5951) protect-promptstd/core/hnd/protect-prompt: (resumed : ref<global,bool>, k : (resume-result<$5949,$5951>) -> $5950 $5951, res : $5951) -> $5950 $5951(resumedresumed: ref<global,bool>,kk: (resume-result<$5949,$5951>) -> $5950 $5951,resres: $5951) /* pub fun clause-control1( clause : (x:a, k: b -> e r) -> e r ) : clause1<a,b,e,r> Clause1(fn(m,w,x){ yield-to(m, fn(k){ clause(x, fn(r){ k({r}) } ) }) }) */ // generic control clause pub fun clause-control1std/core/hnd/clause-control1: forall<a,b,e,c,d> (clause : (x : a, k : (b) -> e d) -> e d) -> clause1<a,b,c,e,d>( clauseclause: (x : $6071, k : ($6072) -> $6073 $6075) -> $6073 $6075 : (x:aa: V, k: bb: V -> ee: E rr: V) -> ee: E rr: V )result: -> total clause1<6148,6149,6151,6150,6152> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>(fnfn: (m : marker<$6073,$6075>, ev<$6074>, x : $6071) -> $6073 $6072(mm: marker<$6073,$6075>,_ev,xx: $6071){ yield-tostd/core/hnd/yield-to: (m : marker<$6073,$6075>, clause : ((resume-result<$6072,$6075>) -> $6073 $6075) -> $6073 $6075) -> $6073 $6072(mm: marker<$6073,$6075>, fnfn: (k : (resume-result<$6072,$6075>) -> $6073 $6075) -> $6073 $6075(kk: (resume-result<$6072,$6075>) -> $6073 $6075) protectstd/core/hnd/protect: (x : $6071, clause : (x : $6071, k : ($6072) -> $6073 $6075) -> $6073 $6075, k : (resume-result<$6072,$6075>) -> $6073 $6075) -> $6073 $6075(xx: $6071,clauseclause: (x : $6071, k : ($6072) -> $6073 $6075) -> $6073 $6075,kk: (resume-result<$6072,$6075>) -> $6073 $6075) ) }) // tail-resumptive clause: resumes exactly once at the end // (these can be executed 'in-place' without capturing a resumption) pub fun clause-tail1std/core/hnd/clause-tail1: forall<e,a,b,c,d> (op : (c) -> e d) -> clause1<c,d,b,e,a><ee: E,rr: V,hh: (E, V) -> V,aa: V,bb: V>(opop: ($6172) -> $6169 $6173 : aa: V -> ee: E bb: V)result: -> total clause1<6236,6237,6235,6233,6234> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>(fnfn: (marker<$6169,$6170>, ev : ev<$6171>, x : $6172) -> $6169 $6173(_m,evev: ev<$6171>,xx: $6172){ under1std/core/hnd/under1: (ev : ev<$6171>, op : ($6172) -> $6169 $6173, x : $6172) -> $6169 $6173(evev: ev<$6171>,opop: ($6172) -> $6169 $6173,xx: $6172) }) // tail-resumptive clause that does not itself invoke operations // (these can be executed 'in-place' without setting the correct evidence vector) pub fun clause-tail-noop1std/core/hnd/clause-tail-noop1: forall<e,a,b,c,d> (op : (c) -> e d) -> clause1<c,d,b,e,a><ee: E,rr: V,hh: (E, V) -> V,aa: V,bb: V>(opop: ($6257) -> $6254 $6258 : aa: V -> ee: E bb: V)result: -> total clause1<6307,6308,6306,6304,6305> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>(fnfn: (marker<$6254,$6255>, ev<$6256>, x : $6257) -> $6254 $6258(_m,_ev,xx: $6257){ opop: ($6257) -> $6254 $6258(xx: $6257) }) // clause that never resumes (e.g. an exception handler) // (these do not need to capture a resumption and execute finally clauses upfront) pub fun clause-never1std/core/hnd/clause-never1: forall<a,b,e,c,d> (op : (a) -> e d) -> clause1<a,b,c,e,d>( opop: ($6325) -> $6327 $6329 : aa: V -> ee: E rr: V )result: -> total clause1<6391,6392,6394,6393,6395> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>(fnfn: (m : marker<$6327,$6329>, ev<$6328>, x : $6325) -> $6327 $6326(mm: marker<$6327,$6329>,_ev,xx: $6325){ yield-to-finalstd/core/hnd/yield-to-final: (m : marker<$6327,$6329>, clause : ((resume-result<$6326,$6329>) -> $6327 $6329) -> $6327 $6329) -> $6327 $6326(mm: marker<$6327,$6329>, fnfn: ((resume-result<$6326,$6329>) -> $6327 $6329) -> $6327 $6329(_k) opop: ($6325) -> $6327 $6329(xx: $6325) ) }) //---------------------------------------------------------------- // 0 arguments; reuse 1 argument Clauses //---------------------------------------------------------------- abstract value type clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>( clausestd/core/hnd/clause0/clause: forall<a,b,e,c> (clause0 : clause0<a,b,e,c>) -> ((marker<e,c>, ev<b>) -> e a): (markerstd/core/hnd/marker: (E, V) -> V<ee: E,rr: V>, evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>) -> ee: E bb: V ) //inline extern cast-hnd( h : h<e1,r> ) : e h<e,r> { inline "#1"//inline extern cast-marker( m : marker<e1,r> ) : e marker<e,r> { inline "#1" pub inline fun @perform0( evev: ev<$6542> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: forall<e,a> ($6542<e,a>) -> clause0<$6540,$6542,e,a> : (forall<e1e1: E,rr: V> hh: (E, V) -> V<e1e1: E,rr: V> -> clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,e1e1: E,rr: V>) )result: -> 6618 6617 : ee: E bb: V match evev: ev<$6542> Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(_tag,mm: marker<$6548,$6549>,hh: $6542<$6548,$6549>,_w) -> match hh: $6542<$6548,$6549>.opop: ($6542<$6548,$6549>) -> $6541 clause0<$6540,$6542,$6548,$6549> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>(ff: (marker<$6548,$6549>, ev<$6542>) -> $6548 $6540) -> cast-clause0std/core/hnd/cast-clause0: (f : (marker<$6548,$6549>, ev<$6542>) -> $6548 $6540) -> $6541 ((marker<$6548,$6549>, ev<$6542>) -> $6541 $6540)(ff: (marker<$6548,$6549>, ev<$6542>) -> $6548 $6540)(mm: marker<$6548,$6549>,evev: ev<$6542>) inline fun under0std/core/hnd/under0: forall<a,e,b> (ev : ev<b>, op : () -> e a) -> e a( evev: ev<$6633> : evstd/core/hnd/ev: ((E, V) -> V) -> V<ii: (E, V) -> V>, opop: () -> $6632 $6631 : () -> ee: E bb: V)result: -> 6716 6715 : ee: E bb: V val w0w0: evv<_6641> = evv-swap-withstd/core/hnd/evv-swap-with: (ev : ev<$6633>) -> $6632 evv<_6641>(evev: ev<$6633>) val yy: $6631 = opop: () -> $6632 $6631() // evv-set(w0) // only needed before yielding for evidence expected check in prompt evv-setstd/core/hnd/evv-set: (w : evv<_6641>) -> $6632 ()(w0w0: evv<_6641>) if yieldingstd/core/hnd/yielding: () -> $6632 bool() returnreturn: $6631 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $6632 $6631, a) -> $6632 $6631) -> $6632 $6631( fnfn: forall<a> (cont : (a) -> $6632 $6631, res : a) -> $6632 $6631(contcont: ($6673) -> $6632 $6631,resres: $6673) under1std/core/hnd/under1: (ev : ev<$6633>, op : ($6673) -> $6632 $6631, x : $6673) -> $6632 $6631(evev: ev<$6633>,contcont: ($6673) -> $6632 $6631,resres: $6673) )std/core/types/Unit: () yy: $6631 pub fun clause-control-raw0std/core/hnd/clause-control-raw0: forall<a,e,e1,b,c> (op : (resume-context<a,e,e1,c>) -> e c) -> clause0<a,b,e,c>( opop: (resume-context<$6727,$6728,$6729,$6731>) -> $6728 $6731 : resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E,e0e0: E,rr: V> -> ee: E rr: V )result: -> total clause0<6803,6806,6804,6807> : clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>(fnfn: (m : marker<$6728,$6731>, ev<$6730>) -> $6728 $6727(mm: marker<$6728,$6731>,_ev){ yield-tostd/core/hnd/yield-to: (m : marker<$6728,$6731>, clause : ((resume-result<$6727,$6731>) -> $6728 $6731) -> $6728 $6731) -> $6728 $6727(mm: marker<$6728,$6731>, fnfn: (k : (resume-result<$6727,$6731>) -> $6728 $6731) -> $6728 $6731(kk: (resume-result<$6727,$6731>) -> $6728 $6731){ opop: (resume-context<$6727,$6728,$6729,$6731>) -> $6728 $6731(Resume-contextstd/core/hnd/Resume-context: forall<a,e,e1,b> (k : (resume-result<a,b>) -> e b) -> resume-context<a,e,e1,b>(kk: (resume-result<$6727,$6731>) -> $6728 $6731)) } ) }) /* pub fun clause-control0( op : (b -> e r) -> e r ) : clause0<b,e,r> Clause0(fn(m,w){ yield-to(m, fn(k){ op(fn(r){ k({r} )}) }) }) */ pub fun clause-control0std/core/hnd/clause-control0: forall<a,e,b,c> (op : ((a) -> e c) -> e c) -> clause0<a,b,e,c>( opop: (($6824) -> $6825 $6827) -> $6825 $6827 : (bb: V -> ee: E rr: V) -> ee: E rr: V )result: -> total clause0<6896,6898,6897,6899> : clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>(fnfn: (m : marker<$6825,$6827>, ev<$6826>) -> $6825 $6824(mm: marker<$6825,$6827>,_ev){ yield-tostd/core/hnd/yield-to: (m : marker<$6825,$6827>, clause : ((resume-result<$6824,$6827>) -> $6825 $6827) -> $6825 $6827) -> $6825 $6824(mm: marker<$6825,$6827>, fnfn: (k : (resume-result<$6824,$6827>) -> $6825 $6827) -> $6825 $6827(kk: (resume-result<$6824,$6827>) -> $6825 $6827){ protectstd/core/hnd/protect: (x : (), clause : (x : (), k : ($6824) -> $6825 $6827) -> $6825 $6827, k : (resume-result<$6824,$6827>) -> $6825 $6827) -> $6825 $6827((std/core/types/Unit: ())std/core/types/Unit: (),fnfn: ((), r : ($6824) -> $6825 $6827) -> $6825 $6827(_x,rr: ($6824) -> $6825 $6827){ opop: (($6824) -> $6825 $6827) -> $6825 $6827(rr: ($6824) -> $6825 $6827) }, kk: (resume-result<$6824,$6827>) -> $6825 $6827) }) }) pub fun clause-tail0std/core/hnd/clause-tail0: forall<e,a,b,c> (op : () -> e c) -> clause0<c,b,e,a><ee: E,rr: V,hh: (E, V) -> V,bb: V>(opop: () -> $6913 $6916 : () -> ee: E bb: V)result: -> total clause0<6968,6967,6965,6966> : clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>(fnfn: (marker<$6913,$6914>, ev : ev<$6915>) -> $6913 $6916(_m,evev: ev<$6915>){ under0std/core/hnd/under0: (ev : ev<$6915>, op : () -> $6913 $6916) -> $6913 $6916(evev: ev<$6915>,opop: () -> $6913 $6916) }) pub fun clause-tail-noop0std/core/hnd/clause-tail-noop0: forall<e,a,b,c> (op : () -> e c) -> clause0<c,b,e,a><ee: E,rr: V,hh: (E, V) -> V,bb: V>(opop: () -> $6982 $6985 : () -> ee: E bb: V)result: -> total clause0<7026,7025,7023,7024> : clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>(fnfn: (marker<$6982,$6983>, ev<$6984>) -> $6982 $6985(_m,_ev){ opop: () -> $6982 $6985() }) pub fun clause-valuestd/core/hnd/clause-value: forall<a,e,b,c> (v : a) -> clause0<a,b,e,c>(vv: $7040 : bb: V)result: -> total clause0<7080,7082,7081,7083> : clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>(fnfn: (marker<$7041,$7043>, ev<$7042>) -> $7041 $7040(_m,_ev){ vv: $7040 }) pub fun clause-never0std/core/hnd/clause-never0: forall<a,e,b,c> (op : () -> e c) -> clause0<a,b,e,c>( opop: () -> $7098 $7100 : () -> ee: E rr: V )result: -> total clause0<7154,7156,7155,7157> : clause0std/core/hnd/clause0: (V, (E, V) -> V, E, V) -> V<bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause0std/core/hnd/Clause0: forall<a,b,e,c> (clause : (marker<e,c>, ev<b>) -> e a) -> clause0<a,b,e,c>(fnfn: (m : marker<$7098,$7100>, ev<$7099>) -> $7098 $7097(mm: marker<$7098,$7100>,_ev){ yield-to-finalstd/core/hnd/yield-to-final: (m : marker<$7098,$7100>, clause : ((resume-result<$7097,$7100>) -> $7098 $7100) -> $7098 $7100) -> $7098 $7097(mm: marker<$7098,$7100>, fnfn: ((resume-result<$7097,$7100>) -> $7098 $7100) -> $7098 $7100(_k){ opop: () -> $7098 $7100() }) }) //---------------------------------------------------------------- // 2 arguments //---------------------------------------------------------------- abstract value type clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a1a1: V,a2a2: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause2std/core/hnd/Clause2: forall<a,b,c,d,e,a1> (clause : (marker<e,a1>, ev<d>, a, b) -> e c) -> clause2<a,b,c,d,e,a1>( clausestd/core/hnd/clause2/clause: forall<a,b,c,d,e,a1> (clause2 : clause2<a,b,c,d,e,a1>) -> ((marker<e,a1>, ev<d>, a, b) -> e c): (markerstd/core/hnd/marker: (E, V) -> V<ee: E,rr: V>, evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, a1a1: V, a2a2: V) -> ee: E bb: V ) fun under2std/core/hnd/under2: forall<a,b,c,e,d> (ev : ev<d>, op : (a, b) -> e c, x1 : a, x2 : b) -> e c( evev: ev<$7355> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: ($7351, $7352) -> $7354 $7353 : (a1a1: V,a2a2: V) -> ee: E bb: V, x1x1: $7351 : a1a1: V, x2x2: $7352 : a2a2: V )result: -> 7450 7449 : ee: E bb: V val w0w0: evv<_7363> = evv-swap-withstd/core/hnd/evv-swap-with: (ev : ev<$7355>) -> $7354 evv<_7363>(evev: ev<$7355>) val zz: $7353 = opop: ($7351, $7352) -> $7354 $7353(x1x1: $7351,x2x2: $7352) evv-setstd/core/hnd/evv-set: (w : evv<_7363>) -> $7354 ()(w0w0: evv<_7363>) if yieldingstd/core/hnd/yielding: () -> $7354 bool() returnreturn: $7353 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $7354 $7353, a) -> $7354 $7353) -> $7354 $7353( fnfn: forall<a> (cont : (a) -> $7354 $7353, res : a) -> $7354 $7353(contcont: ($7397) -> $7354 $7353,resres: $7397) under1std/core/hnd/under1: (ev : ev<$7355>, op : ($7397) -> $7354 $7353, x : $7397) -> $7354 $7353(evev: ev<$7355>,contcont: ($7397) -> $7354 $7353,resres: $7397) )std/core/types/Unit: () zz: $7353 fun protect2std/core/hnd/protect2: forall<a,b,c,e,d> (x1 : a, x2 : b, clause : (x : a, x : b, k : (c) -> e d) -> e d, k : (resume-result<c,d>) -> e d) -> e d( x1x1: $7467 : a1a1: V, x2x2: $7468:a2a2: V, clauseclause: (x : $7467, x : $7468, k : ($7469) -> $7470 $7471) -> $7470 $7471 : (x:a1a1: V,x:a2a2: V, k: bb: V -> ee: E rr: V) -> ee: E rr: V, kk: (resume-result<$7469,$7471>) -> $7470 $7471 : resume-resultstd/core/hnd/resume-result: (V, V) -> V<bb: V,rr: V> -> ee: E rr: V )result: -> 7583 7584 : ee: E rr: V val resumedresumed: ref<global,bool> = (unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$7470> ref<global,bool>) -> $7470 (() -> $7470 ref<global,bool>){refstd/core/types/ref: (value : bool) -> <alloc<global>,read<global>,write<global>|$7470> ref<global,bool>(Falsestd/core/types/False: bool)})() fun kprotectkprotect: (ret : $7469) -> $7470 $7471(retret: $7469)result: -> $7470 $7471 (unsafe-ststd/core/hnd/unsafe-st: (f : () -> <st<global>|$7470> ()) -> $7470 (() -> $7470 ()){ resumedresumed: ref<global,bool> :=std/core/types/set: (ref : ref<global,bool>, assigned : bool) -> <write<global>,alloc<global>,read<global>|$7470> () Truestd/core/types/True: bool })() kk: (resume-result<$7469,$7471>) -> $7470 $7471(Deepstd/core/hnd/Deep: forall<a,b> (result : a) -> resume-result<a,b>(retret: $7469)) val resres: $7471 = clauseclause: (x : $7467, x : $7468, k : ($7469) -> $7470 $7471) -> $7470 $7471(x1x1: $7467,x2x2: $7468,kprotectkprotect: (ret : $7469) -> $7470 $7471) protect-promptstd/core/hnd/protect-prompt: (resumed : ref<global,bool>, k : (resume-result<$7469,$7471>) -> $7470 $7471, res : $7471) -> $7470 $7471(resumedresumed: ref<global,bool>,kk: (resume-result<$7469,$7471>) -> $7470 $7471,resres: $7471) pub fun clause-control2std/core/hnd/clause-control2: forall<a,b,c,e,d,a1> (clause : (x1 : a, x2 : b, k : (c) -> e a1) -> e a1) -> clause2<a,b,c,d,e,a1>( clauseclause: (x1 : $7600, x2 : $7601, k : ($7602) -> $7603 $7605) -> $7603 $7605 : (x1:a1a1: V, x2:a2a2: V, k: bb: V -> ee: E rr: V) -> ee: E rr: V )result: -> total clause2<7689,7690,7691,7693,7692,7694> : clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a1a1: V,a2a2: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause2std/core/hnd/Clause2: forall<a,b,c,d,e,a1> (clause : (marker<e,a1>, ev<d>, a, b) -> e c) -> clause2<a,b,c,d,e,a1>(fnfn: (m : marker<$7603,$7605>, ev<$7604>, x1 : $7600, x2 : $7601) -> $7603 $7602(mm: marker<$7603,$7605>,_ev,x1x1: $7600,x2x2: $7601){ yield-tostd/core/hnd/yield-to: (m : marker<$7603,$7605>, clause : ((resume-result<$7602,$7605>) -> $7603 $7605) -> $7603 $7605) -> $7603 $7602(mm: marker<$7603,$7605>, fnfn: (k : (resume-result<$7602,$7605>) -> $7603 $7605) -> $7603 $7605(kk: (resume-result<$7602,$7605>) -> $7603 $7605){ protect2std/core/hnd/protect2: (x1 : $7600, x2 : $7601, clause : (x : $7600, x : $7601, k : ($7602) -> $7603 $7605) -> $7603 $7605, k : (resume-result<$7602,$7605>) -> $7603 $7605) -> $7603 $7605(x1x1: $7600,x2x2: $7601,clauseclause: (x1 : $7600, x2 : $7601, k : ($7602) -> $7603 $7605) -> $7603 $7605,kk: (resume-result<$7602,$7605>) -> $7603 $7605) }) }) pub fun clause-control-raw2std/core/hnd/clause-control-raw2: forall<a,b,c,e,e1,d,a1> (op : (x1 : a, x2 : b, r : resume-context<c,e,e1,a1>) -> e a1) -> clause2<a,b,c,d,e,a1>( opop: (x1 : $7714, x2 : $7715, r : resume-context<$7716,$7717,$7718,$7720>) -> $7717 $7720 : (x1:a1a1: V, x2:a2a2: V, r: resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E,e0e0: E,rr: V>) -> ee: E rr: V )result: -> total clause2<7808,7809,7810,7813,7811,7814> : clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a1a1: V,a2a2: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause2std/core/hnd/Clause2: forall<a,b,c,d,e,a1> (clause : (marker<e,a1>, ev<d>, a, b) -> e c) -> clause2<a,b,c,d,e,a1>(fnfn: (m : marker<$7717,$7720>, ev<$7719>, x1 : $7714, x2 : $7715) -> $7717 $7716(mm: marker<$7717,$7720>,_ev,x1x1: $7714,x2x2: $7715){ yield-tostd/core/hnd/yield-to: (m : marker<$7717,$7720>, clause : ((resume-result<$7716,$7720>) -> $7717 $7720) -> $7717 $7720) -> $7717 $7716(mm: marker<$7717,$7720>, fnfn: (k : (resume-result<$7716,$7720>) -> $7717 $7720) -> $7717 $7720(kk: (resume-result<$7716,$7720>) -> $7717 $7720){ opop: (x1 : $7714, x2 : $7715, r : resume-context<$7716,$7717,$7718,$7720>) -> $7717 $7720(x1x1: $7714,x2x2: $7715,Resume-contextstd/core/hnd/Resume-context: forall<a,e,e1,b> (k : (resume-result<a,b>) -> e b) -> resume-context<a,e,e1,b>(kk: (resume-result<$7716,$7720>) -> $7717 $7720)) } ) }) pub fun clause-tail2std/core/hnd/clause-tail2: forall<e,a,b,c,d,a1> (op : (c, d) -> e a1) -> clause2<c,d,a1,b,e,a><ee: E,rr: V,hh: (E, V) -> V,a1a1: V,a2a2: V,bb: V>(opop: ($7840, $7841) -> $7837 $7842 : (a1a1: V,a2a2: V) -> ee: E bb: V)result: -> total clause2<7916,7917,7918,7915,7913,7914> : clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a1a1: V,a2a2: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause2std/core/hnd/Clause2: forall<a,b,c,d,e,a1> (clause : (marker<e,a1>, ev<d>, a, b) -> e c) -> clause2<a,b,c,d,e,a1>(fnfn: (m : marker<$7837,$7838>, ev : ev<$7839>, x1 : $7840, x2 : $7841) -> $7837 $7842(mm: marker<$7837,$7838>,evev: ev<$7839>,x1x1: $7840,x2x2: $7841){ under2std/core/hnd/under2: (ev : ev<$7839>, op : ($7840, $7841) -> $7837 $7842, x1 : $7840, x2 : $7841) -> $7837 $7842(evev: ev<$7839>,opop: ($7840, $7841) -> $7837 $7842,x1x1: $7840,x2x2: $7841) }) pub fun clause-tail-noop2std/core/hnd/clause-tail-noop2: forall<e,a,b,c,d,a1> (op : (c, d) -> e a1) -> clause2<c,d,a1,b,e,a><ee: E,rr: V,hh: (E, V) -> V,a1a1: V,a2a2: V,bb: V>(opop: ($7941, $7942) -> $7938 $7943 : (a1a1: V,a2a2: V) -> ee: E bb: V)result: -> total clause2<8000,8001,8002,7999,7997,7998> : clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a1a1: V,a2a2: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause2std/core/hnd/Clause2: forall<a,b,c,d,e,a1> (clause : (marker<e,a1>, ev<d>, a, b) -> e c) -> clause2<a,b,c,d,e,a1>(fnfn: (marker<$7938,$7939>, ev<$7940>, x1 : $7941, x2 : $7942) -> $7938 $7943(_m,_ev,x1x1: $7941,x2x2: $7942){ opop: ($7941, $7942) -> $7938 $7943(x1x1: $7941,x2x2: $7942) }) pub inline fun @perform2( evxevx: ev<$8026> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: forall<e,a> ($8026<e,a>) -> clause2<$8022,$8023,$8024,$8026,e,a> : (forall<e1e1: E,rr: V> hh: (E, V) -> V<e1e1: E,rr: V> -> clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,cc: V,hh: (E, V) -> V,e1e1: E,rr: V>), xx: $8022 : aa: V, yy: $8023 : bb: V )result: -> 8124 8123 : ee: E cc: V match evxevx: ev<$8026> Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(_tag,mm: marker<$8032,$8033>,hh: $8026<$8032,$8033>,_w) -> match hh: $8026<$8032,$8033>.opop: ($8026<$8032,$8033>) -> $8025 clause2<$8022,$8023,$8024,$8026,$8032,$8033> Clause2std/core/hnd/Clause2: forall<a,b,c,d,e,a1> (clause : (marker<e,a1>, ev<d>, a, b) -> e c) -> clause2<a,b,c,d,e,a1>(ff: (marker<$8032,$8033>, ev<$8026>, $8022, $8023) -> $8032 $8024) -> cast-clause2std/core/hnd/cast-clause2: (f : (marker<$8032,$8033>, ev<$8026>, $8022, $8023) -> $8032 $8024) -> $8025 ((marker<$8032,$8033>, ev<$8026>, $8022, $8023) -> $8025 $8024)(ff: (marker<$8032,$8033>, ev<$8026>, $8022, $8023) -> $8032 $8024)(mm: marker<$8032,$8033>,evxevx: ev<$8026>,xx: $8022,yy: $8023) pub fun clause-never2std/core/hnd/clause-never2: forall<a,b,c,e,d,a1> (op : (a, b) -> e a1) -> clause2<a,b,c,d,e,a1>( opop: ($8143, $8144) -> $8146 $8148 : (a1a1: V,a2a2: V) -> ee: E rr: V )result: -> total clause2<8218,8219,8220,8222,8221,8223> : clause2std/core/hnd/clause2: (V, V, V, (E, V) -> V, E, V) -> V<a1a1: V,a2a2: V,bb: V,hh: (E, V) -> V,ee: E,rr: V> Clause2std/core/hnd/Clause2: forall<a,b,c,d,e,a1> (clause : (marker<e,a1>, ev<d>, a, b) -> e c) -> clause2<a,b,c,d,e,a1>(fnfn: (m : marker<$8146,$8148>, ev<$8147>, x1 : $8143, x2 : $8144) -> $8146 $8145(mm: marker<$8146,$8148>,_ev,x1x1: $8143,x2x2: $8144){ yield-to-finalstd/core/hnd/yield-to-final: (m : marker<$8146,$8148>, clause : ((resume-result<$8145,$8148>) -> $8146 $8148) -> $8146 $8148) -> $8146 $8145(mm: marker<$8146,$8148>, fnfn: ((resume-result<$8145,$8148>) -> $8146 $8148) -> $8146 $8148(_k){ opop: ($8143, $8144) -> $8146 $8148(x1x1: $8143,x2x2: $8144) }) }) //---------------------------------------------------------------- // 3 arguments: reuse 1 argument clause. // Or should the compiler do tupling/untupling? //---------------------------------------------------------------- // For internal use fun xperform1std/core/hnd/xperform1: forall<a,b,e,c> (ev : ev<c>, op : forall<e1,d> (c<e1,d>) -> clause1<a,b,c,e1,d>, x : a) -> e b( evev: ev<$8246> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: forall<e,a> ($8246<e,a>) -> clause1<$8243,$8244,$8246,e,a> : (forall<e1e1: E,rr: V> hh: (E, V) -> V<e1e1: E,rr: V> -> clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<aa: V,bb: V,hh: (E, V) -> V,e1e1: E,rr: V>), xx: $8243 : aa: V )result: -> 8333 8332 : ee: E bb: V match evev: ev<$8246> Evstd/core/hnd/Ev: forall<a,e,b> (htag : htag<a>, marker : marker<e,b>, hnd : a<e,b>, hevv : evv<e>) -> ev<a>(_tag,mm: marker<$8252,$8253>,hh: $8246<$8252,$8253>,_w) -> match hh: $8246<$8252,$8253>.opop: ($8246<$8252,$8253>) -> $8245 clause1<$8243,$8244,$8246,$8252,$8253> Clause1std/core/hnd/Clause1: forall<a,b,c,e,d> (clause : (marker<e,d>, ev<c>, a) -> e b) -> clause1<a,b,c,e,d>(ff: (marker<$8252,$8253>, ev<$8246>, $8243) -> $8252 $8244) -> cast-clause1std/core/hnd/cast-clause1: (f : (marker<$8252,$8253>, ev<$8246>, $8243) -> $8252 $8244) -> $8245 ((marker<$8252,$8253>, ev<$8246>, $8243) -> $8245 $8244)(ff: (marker<$8252,$8253>, ev<$8246>, $8243) -> $8252 $8244)(mm: marker<$8252,$8253>,evev: ev<$8246>,xx: $8243) pub fun clause-control-raw3std/core/hnd/clause-control-raw3: forall<a,b,c,d,e,e1,a1,b1> (op : (x1 : a, x2 : b, x3 : c, r : resume-context<d,e,e1,b1>) -> e b1) -> clause1<(a, b, c),d,a1,e,b1>( opop: (x1 : $8349, x2 : $8350, x3 : $8351, r : resume-context<$8352,$8353,$8354,$8356>) -> $8353 $8356 : (x1:a1a1: V, x2:a2a2: V, x3:a3a3: V, r: resume-contextstd/core/hnd/resume-context: (V, E, E, V) -> V<bb: V,ee: E,e0e0: E,rr: V>) -> ee: E rr: V )result: -> total clause1<(8430, 8431, 8432),8433,8436,8434,8437> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple3: (V, V, V) -> Va1a1: V,a2a2: V,a3a3: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-control-raw1std/core/hnd/clause-control-raw1: (op : (x : ($8349, $8350, $8351), r : resume-context<$8352,$8353,$8354,$8356>) -> $8353 $8356) -> clause1<($8349, $8350, $8351),$8352,$8355,$8353,$8356>( fnfn: (($8349, $8350, $8351), r : resume-context<$8352,$8353,$8354,$8356>) -> $8353 $8356((std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)x1x1: $8349,x2x2: $8350,x3x3: $8351)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c),rr: resume-context<$8352,$8353,$8354,$8356>){ opop: (x1 : $8349, x2 : $8350, x3 : $8351, r : resume-context<$8352,$8353,$8354,$8356>) -> $8353 $8356(x1x1: $8349,x2x2: $8350,x3x3: $8351,rr: resume-context<$8352,$8353,$8354,$8356>) } ) pub fun clause-control3std/core/hnd/clause-control3: forall<a,b,c,d,e,a1,b1> (op : (x1 : a, x2 : b, x3 : c, k : (d) -> e b1) -> e b1) -> clause1<(a, b, c),d,a1,e,b1>( opop: (x1 : $8463, x2 : $8464, x3 : $8465, k : ($8466) -> $8467 $8469) -> $8467 $8469 : (x1:a1a1: V, x2:a2a2: V, x3:a3a3: V, k: bb: V -> ee: E rr: V) -> ee: E rr: V )result: -> total clause1<(8536, 8537, 8538),8539,8541,8540,8542> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple3: (V, V, V) -> Va1a1: V,a2a2: V,a3a3: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-control1std/core/hnd/clause-control1: (clause : (x : ($8463, $8464, $8465), k : ($8466) -> $8467 $8469) -> $8467 $8469) -> clause1<($8463, $8464, $8465),$8466,$8468,$8467,$8469>( fnfn: (($8463, $8464, $8465), k : ($8466) -> $8467 $8469) -> $8467 $8469((std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)x1x1: $8463,x2x2: $8464,x3x3: $8465)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c),kk: ($8466) -> $8467 $8469){ opop: (x1 : $8463, x2 : $8464, x3 : $8465, k : ($8466) -> $8467 $8469) -> $8467 $8469(x1x1: $8463,x2x2: $8464,x3x3: $8465,kk: ($8466) -> $8467 $8469) } ) pub fun clause-tail3std/core/hnd/clause-tail3: forall<e,a,b,c,d,a1,b1> (op : (c, d, a1) -> e b1) -> clause1<(c, d, a1),b1,b,e,a><ee: E,rr: V,hh: (E, V) -> V,a1a1: V,a2a2: V,a3a3: V,bb: V>(opop: ($8568, $8569, $8570) -> $8565 $8571 : (a1a1: V,a2a2: V,a3a3: V) -> ee: E bb: V)result: -> total clause1<(8640, 8641, 8642),8643,8639,8637,8638> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple3: (V, V, V) -> Va1a1: V,a2a2: V,a3a3: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-tail1std/core/hnd/clause-tail1: (op : (($8568, $8569, $8570)) -> $8565 $8571) -> clause1<($8568, $8569, $8570),$8571,$8567,$8565,$8566>( fnfn: (($8568, $8569, $8570)) -> $8565 $8571((std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)x1x1: $8568,x2x2: $8569,x3x3: $8570)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) ){ opop: ($8568, $8569, $8570) -> $8565 $8571(x1x1: $8568,x2x2: $8569,x3x3: $8570) } ) pub fun clause-tail-noop3std/core/hnd/clause-tail-noop3: forall<e,a,b,c,d,a1,b1> (op : (c, d, a1) -> e b1) -> clause1<(c, d, a1),b1,b,e,a><ee: E,rr: V,hh: (E, V) -> V,a1a1: V,a2a2: V,a3a3: V,bb: V>(opop: ($8669, $8670, $8671) -> $8666 $8672 : (a1a1: V,a2a2: V,a3a3: V) -> ee: E bb: V)result: -> total clause1<(8741, 8742, 8743),8744,8740,8738,8739> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple3: (V, V, V) -> Va1a1: V,a2a2: V,a3a3: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-tail-noop1std/core/hnd/clause-tail-noop1: (op : (($8669, $8670, $8671)) -> $8666 $8672) -> clause1<($8669, $8670, $8671),$8672,$8668,$8666,$8667>( fnfn: (($8669, $8670, $8671)) -> $8666 $8672((std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)x1x1: $8669,x2x2: $8670,x3x3: $8671)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)){ opop: ($8669, $8670, $8671) -> $8666 $8672(x1x1: $8669,x2x2: $8670,x3x3: $8671) } ) pub fun clause-never3std/core/hnd/clause-never3: forall<a,b,c,d,e,a1,b1> (op : (a, b, c) -> e b1) -> clause1<(a, b, c),d,a1,e,b1>( opop: ($8767, $8768, $8769) -> $8771 $8773 : (a1a1: V,a2a2: V,a3a3: V) -> ee: E rr: V )result: -> total clause1<(8839, 8840, 8841),8842,8844,8843,8845> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple3: (V, V, V) -> Va1a1: V,a2a2: V,a3a3: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-never1std/core/hnd/clause-never1: (op : (($8767, $8768, $8769)) -> $8771 $8773) -> clause1<($8767, $8768, $8769),$8770,$8772,$8771,$8773>(fnfn: (($8767, $8768, $8769)) -> $8771 $8773((std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)x1x1: $8767,x2x2: $8768,x3x3: $8769)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)){ opop: ($8767, $8768, $8769) -> $8771 $8773(x1x1: $8767,x2x2: $8768,x3x3: $8769) } ) pub fun @perform3( evev: ev<$8873> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: forall<e,a> ($8873<e,a>) -> clause1<($8868, $8869, $8870),$8871,$8873,e,a> : (forall<e1e1: E,rr: V> hh: (E, V) -> V<e1e1: E,rr: V> -> clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple3: (V, V, V) -> Va1a1: V,a2a2: V,a3a3: V),bb: V,hh: (E, V) -> V,e1e1: E,rr: V>), x1x1: $8868 : a1a1: V, x2x2: $8869 : a2a2: V, x3x3: $8870 : a3a3: V )result: -> 8953 8952 : ee: E bb: V xperform1std/core/hnd/xperform1: (ev : ev<$8873>, op : forall<e,a> ($8873<e,a>) -> clause1<($8868, $8869, $8870),$8871,$8873,e,a>, x : ($8868, $8869, $8870)) -> $8872 $8871(evev: ev<$8873>,opop: forall<e,a> ($8873<e,a>) -> clause1<($8868, $8869, $8870),$8871,$8873,e,a>,(std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)x1x1: $8868,x2x2: $8869,x3x3: $8870)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)) fun under3std/core/hnd/under3: forall<a,b,c,d,e,a1> (ev : ev<a1>, op : (a, b, c) -> e d, x1 : a, x2 : b, x3 : c) -> e d( evev: ev<$8980> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: ($8975, $8976, $8977) -> $8979 $8978 : (a1a1: V,a2a2: V,a3a3: V) -> ee: E bb: V, x1x1: $8975 : a1a1: V, x2x2: $8976 : a2a2: V, x3x3: $8977 : a3a3: V )result: -> 9081 9080 : ee: E bb: V val w0w0: evv<_8988> = evv-swap-withstd/core/hnd/evv-swap-with: (ev : ev<$8980>) -> $8979 evv<_8988>(evev: ev<$8980>) val zz: $8978 = opop: ($8975, $8976, $8977) -> $8979 $8978(x1x1: $8975,x2x2: $8976,x3x3: $8977) evv-setstd/core/hnd/evv-set: (w : evv<_8988>) -> $8979 ()(w0w0: evv<_8988>) if yieldingstd/core/hnd/yielding: () -> $8979 bool() returnreturn: $8978 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $8979 $8978, a) -> $8979 $8978) -> $8979 $8978( fnfn: forall<a> (cont : (a) -> $8979 $8978, res : a) -> $8979 $8978(contcont: ($9023) -> $8979 $8978,resres: $9023) under1std/core/hnd/under1: (ev : ev<$8980>, op : ($9023) -> $8979 $8978, x : $9023) -> $8979 $8978(evev: ev<$8980>,contcont: ($9023) -> $8979 $8978,resres: $9023) )std/core/types/Unit: () zz: $8978 pub fun clause-control4std/core/hnd/clause-control4: forall<a,b,c,d,a1,e,b1,c1> (op : (x1 : a, x2 : b, x3 : c, x4 : d, k : (a1) -> e c1) -> e c1) -> clause1<(a, b, c, d),a1,b1,e,c1>( opop: (x1 : $9101, x2 : $9102, x3 : $9103, x4 : $9104, k : ($9105) -> $9106 $9108) -> $9106 $9108 : (x1:a1a1: V, x2:a2a2: V, x3:a3a3: V, x4:a4a4: V, k: bb: V -> ee: E rr: V) -> ee: E rr: V )result: -> total clause1<(9182, 9183, 9184, 9185),9186,9188,9187,9189> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple4: (V, V, V, V) -> Va1a1: V,a2a2: V,a3a3: V,a4a4: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-control1std/core/hnd/clause-control1: (clause : (x : ($9101, $9102, $9103, $9104), k : ($9105) -> $9106 $9108) -> $9106 $9108) -> clause1<($9101, $9102, $9103, $9104),$9105,$9107,$9106,$9108>( fnfn: (($9101, $9102, $9103, $9104), k : ($9105) -> $9106 $9108) -> $9106 $9108((std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)x1x1: $9101,x2x2: $9102,x3x3: $9103,x4x4: $9104)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d),kk: ($9105) -> $9106 $9108){ opop: (x1 : $9101, x2 : $9102, x3 : $9103, x4 : $9104, k : ($9105) -> $9106 $9108) -> $9106 $9108(x1x1: $9101,x2x2: $9102,x3x3: $9103,x4x4: $9104,kk: ($9105) -> $9106 $9108) } ) pub fun clause-tail4std/core/hnd/clause-tail4: forall<e,a,b,c,d,a1,b1,c1> (op : (c, d, a1, b1) -> e c1) -> clause1<(c, d, a1, b1),c1,b,e,a><ee: E,rr: V,hh: (E, V) -> V,a1a1: V,a2a2: V,a3a3: V,a4a4: V,bb: V>(opop: ($9218, $9219, $9220, $9221) -> $9215 $9222 : (a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> ee: E bb: V)result: -> total clause1<(9298, 9299, 9300, 9301),9302,9297,9295,9296> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple4: (V, V, V, V) -> Va1a1: V,a2a2: V,a3a3: V,a4a4: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-tail1std/core/hnd/clause-tail1: (op : (($9218, $9219, $9220, $9221)) -> $9215 $9222) -> clause1<($9218, $9219, $9220, $9221),$9222,$9217,$9215,$9216>( fnfn: (($9218, $9219, $9220, $9221)) -> $9215 $9222((std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)x1x1: $9218,x2x2: $9219,x3x3: $9220,x4x4: $9221)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)){ opop: ($9218, $9219, $9220, $9221) -> $9215 $9222(x1x1: $9218,x2x2: $9219,x3x3: $9220,x4x4: $9221) } ) pub fun clause-tail-noop4std/core/hnd/clause-tail-noop4: forall<e,a,b,c,d,a1,b1,c1> (op : (c, d, a1, b1) -> e c1) -> clause1<(c, d, a1, b1),c1,b,e,a><ee: E,rr: V,hh: (E, V) -> V,a1a1: V,a2a2: V,a3a3: V,a4a4: V,bb: V>(opop: ($9331, $9332, $9333, $9334) -> $9328 $9335 : (a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> ee: E bb: V)result: -> total clause1<(9411, 9412, 9413, 9414),9415,9410,9408,9409> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple4: (V, V, V, V) -> Va1a1: V,a2a2: V,a3a3: V,a4a4: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-tail-noop1std/core/hnd/clause-tail-noop1: (op : (($9331, $9332, $9333, $9334)) -> $9328 $9335) -> clause1<($9331, $9332, $9333, $9334),$9335,$9330,$9328,$9329>( fnfn: (($9331, $9332, $9333, $9334)) -> $9328 $9335((std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)x1x1: $9331,x2x2: $9332,x3x3: $9333,x4x4: $9334)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)){ opop: ($9331, $9332, $9333, $9334) -> $9328 $9335(x1x1: $9331,x2x2: $9332,x3x3: $9333,x4x4: $9334) } ) pub fun clause-never4std/core/hnd/clause-never4: forall<a,b,c,d,a1,e,b1,c1> (op : (a, b, c, d) -> e c1) -> clause1<(a, b, c, d),a1,b1,e,c1>( opop: ($9441, $9442, $9443, $9444) -> $9446 $9448 : (a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> ee: E rr: V )result: -> total clause1<(9521, 9522, 9523, 9524),9525,9527,9526,9528> : clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple4: (V, V, V, V) -> Va1a1: V,a2a2: V,a3a3: V,a4a4: V),bb: V,hh: (E, V) -> V,ee: E,rr: V> clause-never1std/core/hnd/clause-never1: (op : (($9441, $9442, $9443, $9444)) -> $9446 $9448) -> clause1<($9441, $9442, $9443, $9444),$9445,$9447,$9446,$9448>(fnfn: (($9441, $9442, $9443, $9444)) -> $9446 $9448((std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)x1x1: $9441,x2x2: $9442,x3x3: $9443,x4x4: $9444)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)){ opop: ($9441, $9442, $9443, $9444) -> $9446 $9448(x1x1: $9441,x2x2: $9442,x3x3: $9443,x4x4: $9444) } ) pub fun @perform4( evev: ev<$9560> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: forall<e,a> ($9560<e,a>) -> clause1<($9554, $9555, $9556, $9557),$9558,$9560,e,a> : (forall<e1e1: E,rr: V> hh: (E, V) -> V<e1e1: E,rr: V> -> clause1std/core/hnd/clause1: (V, V, (E, V) -> V, E, V) -> V<(std/core/types/tuple4: (V, V, V, V) -> Va1a1: V,a2a2: V,a3a3: V,a4a4: V),bb: V,hh: (E, V) -> V,e1e1: E,rr: V>), x1x1: $9554 : a1a1: V, x2x2: $9555 : a2a2: V, x3x3: $9556 : a3a3: V, x4x4: $9557 : a4a4: V )result: -> 9649 9648 : ee: E bb: V xperform1std/core/hnd/xperform1: (ev : ev<$9560>, op : forall<e,a> ($9560<e,a>) -> clause1<($9554, $9555, $9556, $9557),$9558,$9560,e,a>, x : ($9554, $9555, $9556, $9557)) -> $9559 $9558(evev: ev<$9560>,opop: forall<e,a> ($9560<e,a>) -> clause1<($9554, $9555, $9556, $9557),$9558,$9560,e,a>,(std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)x1x1: $9554,x2x2: $9555,x3x3: $9556,x4x4: $9557)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)) fun under4std/core/hnd/under4: forall<a,b,c,d,a1,e,b1> (ev : ev<b1>, op : (a, b, c, d) -> e a1, x1 : a, x2 : b, x3 : c, x4 : d) -> e a1( evev: ev<$9680> : evstd/core/hnd/ev: ((E, V) -> V) -> V<hh: (E, V) -> V>, opop: ($9674, $9675, $9676, $9677) -> $9679 $9678 : (a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> ee: E bb: V, x1x1: $9674 : a1a1: V, x2x2: $9675 : a2a2: V, x3x3: $9676 : a3a3: V, x4x4: $9677 : a4a4: V )result: -> 9787 9786 : ee: E bb: V val w0w0: evv<_9688> = evv-swap-withstd/core/hnd/evv-swap-with: (ev : ev<$9680>) -> $9679 evv<_9688>(evev: ev<$9680>) val zz: $9678 = opop: ($9674, $9675, $9676, $9677) -> $9679 $9678(x1x1: $9674,x2x2: $9675,x3x3: $9676,x4x4: $9677) evv-setstd/core/hnd/evv-set: (w : evv<_9688>) -> $9679 ()(w0w0: evv<_9688>) if yieldingstd/core/hnd/yielding: () -> $9679 bool() returnreturn: $9678 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $9679 $9678, a) -> $9679 $9678) -> $9679 $9678( fnfn: forall<a> (cont : (a) -> $9679 $9678, res : a) -> $9679 $9678(contcont: ($9724) -> $9679 $9678,resres: $9724) under1std/core/hnd/under1: (ev : ev<$9680>, op : ($9724) -> $9679 $9678, x : $9724) -> $9679 $9678(evev: ev<$9680>,contcont: ($9724) -> $9679 $9678,resres: $9724) )std/core/types/Unit: () zz: $9678 // ------------------------------------------- // Open // ------------------------------------------- pub fun @open-none0<bb: V,e1e1: E,e2e2: E>( ff: () -> $9811 $9810 : () -> e1e1: E bb: V )result: -> 9858 9856 : e2e2: E bb: V val ww: evv<$9812> = evv-swap-create0std/core/hnd/evv-swap-create0: () -> $9812 evv<$9812>() val xx: $9810 = cast-ev0std/core/hnd/cast-ev0: (f : () -> $9811 $9810) -> $9812 (() -> $9812 $9810)(ff: () -> $9811 $9810)() val keepkeep: () = evv-setstd/core/hnd/evv-set: (w : evv<$9812>) -> $9812 ()(ww: evv<$9812>) xx: $9810 pub fun @open-none1<aa: V,bb: V,e1e1: E,e2e2: E>( ff: ($9868) -> $9870 $9869 : aa: V -> e1e1: E bb: V, x1x1: $9868 : aa: V )result: -> 9926 9924 : e2e2: E bb: V val ww: evv<$9871> = evv-swap-create0std/core/hnd/evv-swap-create0: () -> $9871 evv<$9871>() val xx: $9869 = cast-ev1std/core/hnd/cast-ev1: (f : ($9868) -> $9870 $9869) -> $9871 (($9868) -> $9871 $9869)(ff: ($9868) -> $9870 $9869)(x1x1: $9868) val keepkeep: () = evv-setstd/core/hnd/evv-set: (w : evv<$9871>) -> $9871 ()(ww: evv<$9871>) xx: $9869 pub fun @open-none2<a1a1: V,a2a2: V,bb: V,e1e1: E,e2e2: E>( ff: ($9939, $9940) -> $9942 $9941 : (a1a1: V,a2a2: V) -> e1e1: E bb: V, x1x1: $9939 : a1a1: V, x2x2: $9940 : a2a2: V )result: -> 10007 10005 : e2e2: E bb: V val ww: evv<$9943> = evv-swap-create0std/core/hnd/evv-swap-create0: () -> $9943 evv<$9943>() val xx: $9941 = cast-ev2std/core/hnd/cast-ev2: (f : ($9939, $9940) -> $9942 $9941) -> $9943 (($9939, $9940) -> $9943 $9941)(ff: ($9939, $9940) -> $9942 $9941)(x1x1: $9939,x2x2: $9940) val keepkeep: () = evv-setstd/core/hnd/evv-set: (w : evv<$9943>) -> $9943 ()(ww: evv<$9943>) xx: $9941 pub fun @open-none3<a1a1: V,a2a2: V,a3a3: V,bb: V,e1e1: E,e2e2: E>( ff: ($10023, $10024, $10025) -> $10027 $10026 : (a1a1: V,a2a2: V,a3a3: V) -> e1e1: E bb: V, x1x1: $10023 : a1a1: V, x2x2: $10024 : a2a2: V, x3x3: $10025 : a3a3: V )result: -> 10101 10099 : e2e2: E bb: V val ww: evv<$10028> = evv-swap-create0std/core/hnd/evv-swap-create0: () -> $10028 evv<$10028>() val xx: $10026 = cast-ev3std/core/hnd/cast-ev3: (f : ($10023, $10024, $10025) -> $10027 $10026) -> $10028 (($10023, $10024, $10025) -> $10028 $10026)(ff: ($10023, $10024, $10025) -> $10027 $10026)(x1x1: $10023,x2x2: $10024,x3x3: $10025) val keepkeep: () = evv-setstd/core/hnd/evv-set: (w : evv<$10028>) -> $10028 ()(ww: evv<$10028>) xx: $10026 pub fun @open-none4<a1a1: V,a2a2: V,a3a3: V,a4a4: V,bb: V,e1e1: E,e2e2: E>( ff: ($10120, $10121, $10122, $10123) -> $10125 $10124 : (a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> e1e1: E bb: V, x1x1: $10120 : a1a1: V, x2x2: $10121 : a2a2: V, x3x3: $10122 : a3a3: V, x4x4: $10123 : a4a4: V )result: -> 10208 10206 : e2e2: E bb: V val ww: evv<$10126> = evv-swap-create0std/core/hnd/evv-swap-create0: () -> $10126 evv<$10126>() val xx: $10124 = cast-ev4std/core/hnd/cast-ev4: (f : ($10120, $10121, $10122, $10123) -> $10125 $10124) -> $10126 (($10120, $10121, $10122, $10123) -> $10126 $10124)(ff: ($10120, $10121, $10122, $10123) -> $10125 $10124)(x1x1: $10120,x2x2: $10121,x3x3: $10122,x4x4: $10123) val keepkeep: () = evv-setstd/core/hnd/evv-set: (w : evv<$10126>) -> $10126 ()(ww: evv<$10126>) xx: $10124 noinline fun open-at1std/core/hnd/open-at1: forall<a,b,e,e1> (i : ev-index, f : (a) -> e b, x : a) -> e1 b<aa: V,bb: V,e1e1: E,e2e2: E>( ii: ev-index: ev-indexstd/core/hnd/ev-index: V, ff: ($10230) -> $10232 $10231 : aa: V -> e1e1: E bb: V, xx: $10230 : aa: V )result: -> 10341 10339 : e2e2: E bb: V val ww: evv<$10233> = evv-swap-create1std/core/hnd/evv-swap-create1: (i : ev-index) -> $10233 evv<$10233>(ii: ev-index) val yy: $10231 = cast-ev1std/core/hnd/cast-ev1: (f : ($10230) -> $10232 $10231) -> $10233 (($10230) -> $10233 $10231)(ff: ($10230) -> $10232 $10231)(xx: $10230) evv-setstd/core/hnd/evv-set: (w : evv<$10233>) -> $10233 ()(ww: evv<$10233>) if yieldingstd/core/hnd/yielding: () -> $10233 bool() returnreturn: $10231 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $10233 $10231, a) -> $10233 $10231) -> $10233 $10231(fnfn: forall<a> (cont : (a) -> $10233 $10231, res : a) -> $10233 $10231(contcont: ($10285) -> $10233 $10231,resres: $10285){ open-at1std/core/hnd/open-at1: (i : ev-index, f : ($10285) -> $10233 $10231, x : $10285) -> $10233 $10231(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : ev-index) -> $10233 ev-index(ii: ev-index),contcont: ($10285) -> $10233 $10231,resres: $10285) })std/core/types/Unit: () yy: $10231 pub fun @open-at0<bb: V,e1e1: E,e2e2: E>( ii: ev-index: ev-indexstd/core/hnd/ev-index: V, ff: () -> $10355 $10354 : () -> e1e1: E bb: V )result: -> 10448 10446 : e2e2: E bb: V val ww: evv<$10356> = evv-swap-create1std/core/hnd/evv-swap-create1: (i : ev-index) -> $10356 evv<$10356>(ii: ev-index) val yy: $10354 = cast-ev0std/core/hnd/cast-ev0: (f : () -> $10355 $10354) -> $10356 (() -> $10356 $10354)(ff: () -> $10355 $10354)() evv-setstd/core/hnd/evv-set: (w : evv<$10356>) -> $10356 ()(ww: evv<$10356>) if yieldingstd/core/hnd/yielding: () -> $10356 bool() returnreturn: $10354 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $10356 $10354, a) -> $10356 $10354) -> $10356 $10354(fnfn: forall<a> (cont : (a) -> $10356 $10354, res : a) -> $10356 $10354(contcont: ($10404) -> $10356 $10354,resres: $10404){ open-at1std/core/hnd/open-at1: (i : ev-index, f : ($10404) -> $10356 $10354, x : $10404) -> $10356 $10354(ii: ev-index,contcont: ($10404) -> $10356 $10354,resres: $10404) })std/core/types/Unit: () yy: $10354 pub fun @open-at1<aa: V,bb: V,e1e1: E,e2e2: E>( ii: ev-index: ev-indexstd/core/hnd/ev-index: V, ff: ($10458) -> $10460 $10459 : aa: V -> e1e1: E bb: V, xx: $10458 : aa: V )result: -> 10562 10560 : e2e2: E bb: V val ww: evv<$10461> = evv-swap-create1std/core/hnd/evv-swap-create1: (i : ev-index) -> $10461 evv<$10461>(ii: ev-index) val yy: $10459 = cast-ev1std/core/hnd/cast-ev1: (f : ($10458) -> $10460 $10459) -> $10461 (($10458) -> $10461 $10459)(ff: ($10458) -> $10460 $10459)(xx: $10458) evv-setstd/core/hnd/evv-set: (w : evv<$10461>) -> $10461 ()(ww: evv<$10461>) if yieldingstd/core/hnd/yielding: () -> $10461 bool() returnreturn: $10459 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $10461 $10459, a) -> $10461 $10459) -> $10461 $10459(fnfn: forall<a> (cont : (a) -> $10461 $10459, res : a) -> $10461 $10459(contcont: ($10513) -> $10461 $10459,resres: $10513){ open-at1std/core/hnd/open-at1: (i : ev-index, f : ($10513) -> $10461 $10459, x : $10513) -> $10461 $10459(ii: ev-index,contcont: ($10513) -> $10461 $10459,resres: $10513) })std/core/types/Unit: () yy: $10459 pub fun @open-at2<a1a1: V,a2a2: V,bb: V,e1e1: E,e2e2: E> ( ii: ev-index: ev-indexstd/core/hnd/ev-index: V, ff: ($10575, $10576) -> $10578 $10577 : (a1a1: V,a2a2: V) -> e1e1: E bb: V, x1x1: $10575 : a1a1: V, x2x2: $10576 : a2a2: V )result: -> 10689 10687 : e2e2: E bb: V val ww: evv<$10579> = evv-swap-create1std/core/hnd/evv-swap-create1: (i : ev-index) -> $10579 evv<$10579>(ii: ev-index) val yy: $10577 = cast-ev2std/core/hnd/cast-ev2: (f : ($10575, $10576) -> $10578 $10577) -> $10579 (($10575, $10576) -> $10579 $10577)(ff: ($10575, $10576) -> $10578 $10577)(x1x1: $10575,x2x2: $10576) evv-setstd/core/hnd/evv-set: (w : evv<$10579>) -> $10579 ()(ww: evv<$10579>) if yieldingstd/core/hnd/yielding: () -> $10579 bool() returnreturn: $10577 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $10579 $10577, a) -> $10579 $10577) -> $10579 $10577(fnfn: forall<a> (cont : (a) -> $10579 $10577, res : a) -> $10579 $10577(contcont: ($10635) -> $10579 $10577,resres: $10635){ open-at1std/core/hnd/open-at1: (i : ev-index, f : ($10635) -> $10579 $10577, x : $10635) -> $10579 $10577(ii: ev-index,contcont: ($10635) -> $10579 $10577,resres: $10635) })std/core/types/Unit: () yy: $10577 pub fun @open-at3<a1a1: V,a2a2: V,a3a3: V,bb: V,e1e1: E,e2e2: E> ( ii: ev-index: ev-indexstd/core/hnd/ev-index: V, ff: ($10705, $10706, $10707) -> $10709 $10708 : (a1a1: V,a2a2: V,a3a3: V) -> e1e1: E bb: V, x1x1: $10705 : a1a1: V, x2x2: $10706 : a2a2: V, x3x3: $10707 : a3a3: V )result: -> 10829 10827 : e2e2: E bb: V val ww: evv<$10710> = evv-swap-create1std/core/hnd/evv-swap-create1: (i : ev-index) -> $10710 evv<$10710>(ii: ev-index) val yy: $10708 = cast-ev3std/core/hnd/cast-ev3: (f : ($10705, $10706, $10707) -> $10709 $10708) -> $10710 (($10705, $10706, $10707) -> $10710 $10708)(ff: ($10705, $10706, $10707) -> $10709 $10708)(x1x1: $10705,x2x2: $10706,x3x3: $10707) evv-setstd/core/hnd/evv-set: (w : evv<$10710>) -> $10710 ()(ww: evv<$10710>) if yieldingstd/core/hnd/yielding: () -> $10710 bool() returnreturn: $10708 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $10710 $10708, a) -> $10710 $10708) -> $10710 $10708(fnfn: forall<a> (cont : (a) -> $10710 $10708, res : a) -> $10710 $10708(contcont: ($10770) -> $10710 $10708,resres: $10770){ open-at1std/core/hnd/open-at1: (i : ev-index, f : ($10770) -> $10710 $10708, x : $10770) -> $10710 $10708(ii: ev-index,contcont: ($10770) -> $10710 $10708,resres: $10770) })std/core/types/Unit: () yy: $10708 pub fun @open-at4<a1a1: V,a2a2: V,a3a3: V,a4a4: V,bb: V,e1e1: E,e2e2: E> ( ii: ev-index: ev-indexstd/core/hnd/ev-index: V, ff: ($10848, $10849, $10850, $10851) -> $10853 $10852 : (a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> e1e1: E bb: V, x1x1: $10848 : a1a1: V, x2x2: $10849 : a2a2: V, x3x3: $10850 : a3a3: V, x4x4: $10851 : a4a4: V )result: -> 10982 10980 : e2e2: E bb: V val ww: evv<$10854> = evv-swap-create1std/core/hnd/evv-swap-create1: (i : ev-index) -> $10854 evv<$10854>(ii: ev-index) val yy: $10852 = cast-ev4std/core/hnd/cast-ev4: (f : ($10848, $10849, $10850, $10851) -> $10853 $10852) -> $10854 (($10848, $10849, $10850, $10851) -> $10854 $10852)(ff: ($10848, $10849, $10850, $10851) -> $10853 $10852)(x1x1: $10848,x2x2: $10849,x3x3: $10850,x4x4: $10851) evv-setstd/core/hnd/evv-set: (w : evv<$10854>) -> $10854 ()(ww: evv<$10854>) if yieldingstd/core/hnd/yielding: () -> $10854 bool() returnreturn: $10852 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $10854 $10852, a) -> $10854 $10852) -> $10854 $10852(fnfn: forall<a> (cont : (a) -> $10854 $10852, res : a) -> $10854 $10852(contcont: ($10918) -> $10854 $10852,resres: $10918){ open-at1std/core/hnd/open-at1: (i : ev-index, f : ($10918) -> $10854 $10852, x : $10918) -> $10854 $10852(ii: ev-index,contcont: ($10918) -> $10854 $10852,resres: $10918) })std/core/types/Unit: () yy: $10852 noinline fun open1std/core/hnd/open1: forall<a,b,e,e1> (indices : vector<ev-index>, f : (a) -> e b, x : a) -> e1 b<aa: V,bb: V,e1e1: E,e2e2: E>( indicesindices: vector<ev-index> : vectorstd/core/types/vector: V -> V<ev-indexstd/core/hnd/ev-index: V>, ff: ($11004) -> $11006 $11005 : aa: V -> e1e1: E bb: V, xx: $11004 : aa: V )result: -> 11115 11113 : e2e2: E bb: V val ww: evv<$11007> = evv-swap-createstd/core/hnd/evv-swap-create: (indices : vector<ev-index>) -> $11007 evv<$11007>(indicesindices: vector<ev-index>) val yy: $11005 = cast-ev1std/core/hnd/cast-ev1: (f : ($11004) -> $11006 $11005) -> $11007 (($11004) -> $11007 $11005)(ff: ($11004) -> $11006 $11005)(xx: $11004) evv-setstd/core/hnd/evv-set: (w : evv<$11007>) -> $11007 ()(ww: evv<$11007>) if yieldingstd/core/hnd/yielding: () -> $11007 bool() returnreturn: $11005 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $11007 $11005, a) -> $11007 $11005) -> $11007 $11005(fnfn: forall<a> (cont : (a) -> $11007 $11005, res : a) -> $11007 $11005(contcont: ($11059) -> $11007 $11005,resres: $11059){ open1std/core/hnd/open1: (indices : vector<ev-index>, f : ($11059) -> $11007 $11005, x : $11059) -> $11007 $11005(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : vector<ev-index>) -> $11007 vector<ev-index>(indicesindices: vector<ev-index>),contcont: ($11059) -> $11007 $11005,resres: $11059) })std/core/types/Unit: () yy: $11005 pub fun @open0<bb: V,e1e1: E,e2e2: E>( indicesindices: vector<ev-index> : vectorstd/core/types/vector: V -> V<ev-indexstd/core/hnd/ev-index: V>, ff: () -> $11129 $11128 : () -> e1e1: E bb: V )result: -> 11222 11220 : e2e2: E bb: V val ww: evv<$11130> = evv-swap-createstd/core/hnd/evv-swap-create: (indices : vector<ev-index>) -> $11130 evv<$11130>(indicesindices: vector<ev-index>) val yy: $11128 = cast-ev0std/core/hnd/cast-ev0: (f : () -> $11129 $11128) -> $11130 (() -> $11130 $11128)(ff: () -> $11129 $11128)() evv-setstd/core/hnd/evv-set: (w : evv<$11130>) -> $11130 ()(ww: evv<$11130>) if yieldingstd/core/hnd/yielding: () -> $11130 bool() returnreturn: $11128 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $11130 $11128, a) -> $11130 $11128) -> $11130 $11128(fnfn: forall<a> (cont : (a) -> $11130 $11128, res : a) -> $11130 $11128(contcont: ($11178) -> $11130 $11128,resres: $11178){ open1std/core/hnd/open1: (indices : vector<ev-index>, f : ($11178) -> $11130 $11128, x : $11178) -> $11130 $11128(indicesindices: vector<ev-index>,contcont: ($11178) -> $11130 $11128,resres: $11178) })std/core/types/Unit: () yy: $11128 pub fun @open1<aa: V,bb: V,e1e1: E,e2e2: E>( indicesindices: vector<ev-index> : vectorstd/core/types/vector: V -> V<ev-indexstd/core/hnd/ev-index: V>, ff: ($11232) -> $11234 $11233 : aa: V -> e1e1: E bb: V, xx: $11232 : aa: V )result: -> 11336 11334 : e2e2: E bb: V val ww: evv<$11235> = evv-swap-createstd/core/hnd/evv-swap-create: (indices : vector<ev-index>) -> $11235 evv<$11235>(indicesindices: vector<ev-index>) val yy: $11233 = cast-ev1std/core/hnd/cast-ev1: (f : ($11232) -> $11234 $11233) -> $11235 (($11232) -> $11235 $11233)(ff: ($11232) -> $11234 $11233)(xx: $11232) evv-setstd/core/hnd/evv-set: (w : evv<$11235>) -> $11235 ()(ww: evv<$11235>) if yieldingstd/core/hnd/yielding: () -> $11235 bool() returnreturn: $11233 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $11235 $11233, a) -> $11235 $11233) -> $11235 $11233(fnfn: forall<a> (cont : (a) -> $11235 $11233, res : a) -> $11235 $11233(contcont: ($11287) -> $11235 $11233,resres: $11287){ open1std/core/hnd/open1: (indices : vector<ev-index>, f : ($11287) -> $11235 $11233, x : $11287) -> $11235 $11233(indicesindices: vector<ev-index>,contcont: ($11287) -> $11235 $11233,resres: $11287) })std/core/types/Unit: () yy: $11233 pub fun @open2<a1a1: V,a2a2: V,bb: V,e1e1: E,e2e2: E>( indicesindices: vector<ev-index> : vectorstd/core/types/vector: V -> V<ev-indexstd/core/hnd/ev-index: V>, ff: ($11349, $11350) -> $11352 $11351 : (a1a1: V,a2a2: V) -> e1e1: E bb: V, x1x1: $11349 : a1a1: V, x2x2: $11350 : a2a2: V )result: -> 11463 11461 : e2e2: E bb: V val ww: evv<$11353> = evv-swap-createstd/core/hnd/evv-swap-create: (indices : vector<ev-index>) -> $11353 evv<$11353>(indicesindices: vector<ev-index>) val yy: $11351 = cast-ev2std/core/hnd/cast-ev2: (f : ($11349, $11350) -> $11352 $11351) -> $11353 (($11349, $11350) -> $11353 $11351)(ff: ($11349, $11350) -> $11352 $11351)(x1x1: $11349,x2x2: $11350) evv-setstd/core/hnd/evv-set: (w : evv<$11353>) -> $11353 ()(ww: evv<$11353>) if yieldingstd/core/hnd/yielding: () -> $11353 bool() returnreturn: $11351 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $11353 $11351, a) -> $11353 $11351) -> $11353 $11351(fnfn: forall<a> (cont : (a) -> $11353 $11351, res : a) -> $11353 $11351(contcont: ($11409) -> $11353 $11351,resres: $11409){ open1std/core/hnd/open1: (indices : vector<ev-index>, f : ($11409) -> $11353 $11351, x : $11409) -> $11353 $11351(indicesindices: vector<ev-index>,contcont: ($11409) -> $11353 $11351,resres: $11409) })std/core/types/Unit: () yy: $11351 pub fun @open3<a1a1: V,a2a2: V,a3a3: V,bb: V,e1e1: E,e2e2: E>( indicesindices: vector<ev-index> : vectorstd/core/types/vector: V -> V<ev-indexstd/core/hnd/ev-index: V>, ff: ($11479, $11480, $11481) -> $11483 $11482 : (a1a1: V,a2a2: V,a3a3: V) -> e1e1: E bb: V, x1x1: $11479 : a1a1: V, x2x2: $11480 : a2a2: V, x3x3: $11481 : a3a3: V )result: -> 11603 11601 : e2e2: E bb: V val ww: evv<$11484> = evv-swap-createstd/core/hnd/evv-swap-create: (indices : vector<ev-index>) -> $11484 evv<$11484>(indicesindices: vector<ev-index>) val yy: $11482 = cast-ev3std/core/hnd/cast-ev3: (f : ($11479, $11480, $11481) -> $11483 $11482) -> $11484 (($11479, $11480, $11481) -> $11484 $11482)(ff: ($11479, $11480, $11481) -> $11483 $11482)(x1x1: $11479,x2x2: $11480,x3x3: $11481) evv-setstd/core/hnd/evv-set: (w : evv<$11484>) -> $11484 ()(ww: evv<$11484>) if yieldingstd/core/hnd/yielding: () -> $11484 bool() returnreturn: $11482 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $11484 $11482, a) -> $11484 $11482) -> $11484 $11482(fnfn: forall<a> (cont : (a) -> $11484 $11482, res : a) -> $11484 $11482(contcont: ($11544) -> $11484 $11482,resres: $11544){ open1std/core/hnd/open1: (indices : vector<ev-index>, f : ($11544) -> $11484 $11482, x : $11544) -> $11484 $11482(indicesindices: vector<ev-index>,contcont: ($11544) -> $11484 $11482,resres: $11544) })std/core/types/Unit: () yy: $11482 pub fun @open4<a1a1: V,a2a2: V,a3a3: V,a4a4: V,bb: V,e1e1: E,e2e2: E>( indicesindices: vector<ev-index> : vectorstd/core/types/vector: V -> V<ev-indexstd/core/hnd/ev-index: V>, ff: ($11622, $11623, $11624, $11625) -> $11627 $11626 : (a1a1: V,a2a2: V,a3a3: V,a4a4: V) -> e1e1: E bb: V, x1x1: $11622 : a1a1: V, x2x2: $11623 : a2a2: V, x3x3: $11624 : a3a3: V, x4x4: $11625 : a4a4: V )result: -> 11756 11754 : e2e2: E bb: V val ww: evv<$11628> = evv-swap-createstd/core/hnd/evv-swap-create: (indices : vector<ev-index>) -> $11628 evv<$11628>(indicesindices: vector<ev-index>) val yy: $11626 = cast-ev4std/core/hnd/cast-ev4: (f : ($11622, $11623, $11624, $11625) -> $11627 $11626) -> $11628 (($11622, $11623, $11624, $11625) -> $11628 $11626)(ff: ($11622, $11623, $11624, $11625) -> $11627 $11626)(x1x1: $11622,x2x2: $11623,x3x3: $11624,x4x4: $11625) evv-setstd/core/hnd/evv-set: (w : evv<$11628>) -> $11628 ()(ww: evv<$11628>) if yieldingstd/core/hnd/yielding: () -> $11628 bool() returnreturn: $11626 yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $11628 $11626, a) -> $11628 $11626) -> $11628 $11626(fnfn: forall<a> (cont : (a) -> $11628 $11626, res : a) -> $11628 $11626(contcont: ($11692) -> $11628 $11626,resres: $11692){ open1std/core/hnd/open1: (indices : vector<ev-index>, f : ($11692) -> $11628 $11626, x : $11692) -> $11628 $11626(indicesindices: vector<ev-index>,contcont: ($11692) -> $11628 $11626,resres: $11692) })std/core/types/Unit: () yy: $11626 // ------------------------------------------- // capture yields // ------------------------------------------- pub fun unsafe-try-finalizestd/core/hnd/unsafe-try-finalize: forall<a,e> (action : () -> e a) -> e either<yield-info,a>( actionaction: () -> $11889 $11888 : () -> ee: E aa: V )result: -> 11910 either<yield-info,11909> : ee: E eitherstd/core/types/either: (V, V) -> V<yield-infostd/core/hnd/yield-info: V,aa: V> try-finalize-promptstd/core/hnd/try-finalize-prompt: (res : $11888) -> $11889 either<yield-info,$11888>(actionaction: () -> $11889 $11888()); fun try-finalize-promptstd/core/hnd/try-finalize-prompt: forall<a,e> (res : a) -> e either<yield-info,a>( resres: $11778 : aa: V )result: -> 11881 either<yield-info,11880> : ee: E eitherstd/core/types/either: (V, V) -> V<yield-infostd/core/hnd/yield-info: V,aa: V> if yielding-non-finalstd/core/hnd/yielding-non-final: () -> $11779 bool() returnreturn: either<yield-info,$11778> yield-contstd/core/hnd/yield-cont: (f : forall<a> ((a) -> $11779 $11778, a) -> $11779 either<yield-info,$11778>) -> $11779 either<yield-info,$11778>(fnfn: forall<a> (cont : (a) -> $11779 $11778, x : a) -> $11779 either<yield-info,$11778>(contcont: ($11797) -> $11779 $11778,xx: $11797) try-finalize-promptstd/core/hnd/try-finalize-prompt: (res : $11778) -> $11779 either<yield-info,$11778>(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : $11778) -> $11779 $11778(contcont: ($11797) -> $11779 $11778(xx: $11797))) )std/core/types/Unit: () if !std/core/types/bool/(!): (b : bool) -> $11779 boolyieldingstd/core/hnd/yielding: () -> $11779 bool() then Rightstd/core/types/Right: forall<a,b> (right : b) -> either<a,b>(resres: $11778) else Leftstd/core/types/Left: forall<a,b> (left : a) -> either<a,b>(yield-capturestd/core/hnd/yield-capture: () -> $11779 yield-info())