Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking control-flow linearity for effect handlers #1173

Merged
merged 76 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
0adf01d
Some attempts on fixing issue 1161:
thwfhk Nov 16, 2022
421c2a8
some tests for the usage of linear variables in handlers
thwfhk Nov 17, 2022
769e047
clean up comments
thwfhk Nov 17, 2022
d204c5a
Fix a bug that params of parameterised handlers can escape the scope …
thwfhk Nov 17, 2022
3207347
clean up comments
thwfhk Nov 17, 2022
2ba1870
clean up comments
thwfhk Nov 17, 2022
cb11dea
deal with linear variables in the return clauses of handlers; add mor…
thwfhk Nov 17, 2022
1d5a151
initial attempt to track control-flow linearity:
thwfhk Dec 2, 2022
2f69150
more proof of concept implementation
thwfhk Dec 2, 2022
b38ed56
Fix and improve the naive implementation of tracking control-flow
thwfhk Dec 5, 2022
8445815
Improve syntax and fix bugs:
thwfhk Dec 6, 2022
68821d4
some minor updates
thwfhk Jan 4, 2023
9e7b867
comments
thwfhk Apr 20, 2023
e99585b
merge with polymorphic operations
thwfhk Jun 4, 2023
b95faa7
Merge branch 'master' into control-flow-linearity
thwfhk Jun 4, 2023
0d9599a
pass all the linear handler tests
thwfhk Jun 4, 2023
24bb4c7
fix the unification of rows with subkinds
thwfhk Jun 4, 2023
834f8e0
improve the choose_and_state examples
thwfhk Jun 5, 2023
aa5d797
syntax for lincase
thwfhk Jun 5, 2023
ecc51eb
fix the linearity checking of unbound continuation
thwfhk Jun 5, 2023
003d517
a potential bug
thwfhk Jun 5, 2023
e087edc
remove some test files
thwfhk Jun 5, 2023
d45d20a
comment some unused functions
thwfhk Jun 5, 2023
bbac798
nullary operations & some lib function signatures
thwfhk Jun 9, 2023
65e4b6d
fix typo in core/typeSugar.ml
thwfhk Jun 9, 2023
712e229
remove dead code
thwfhk Jun 9, 2023
b6e19f9
remove dead code
thwfhk Jun 9, 2023
25b5ec4
remove dead code in core/typeSugar.ml
thwfhk Jun 9, 2023
b5dfc75
Update core/types.mli
thwfhk Jun 9, 2023
f9885e4
use DeclaredLinearity.t instead of ad hoc boolean in the definition o…
thwfhk Jun 26, 2023
f8de147
wrap the linear continuation things in typeSugar.ml into a module
thwfhk Jun 26, 2023
b1a361d
add a flag track-control-flow-linearity
thwfhk Jun 26, 2023
909c599
something
thwfhk Jun 26, 2023
682a5c4
modify the pretty printing for effect rows
thwfhk Jun 26, 2023
19d67dd
modify the pretty printing for function types
thwfhk Jun 26, 2023
a85105b
modify the parser and printer; try to keep the round-tripping property
thwfhk Jun 27, 2023
445ae32
something
thwfhk Jun 27, 2023
c902696
a mess
thwfhk Jun 27, 2023
626cbd2
some attempts to make default Any
thwfhk Jun 29, 2023
20ced3e
add a test example
thwfhk Jun 30, 2023
e67293a
successfully make Any as the default of effect row vars
thwfhk Jun 30, 2023
1e801bc
clean up some tests
thwfhk Jun 30, 2023
df3e053
fix a bug of the effect vars of curried functions
thwfhk Jun 30, 2023
1b57295
fix some bugs (including the parsing of effect presence types)
thwfhk Jun 30, 2023
cc632ab
need to explicitly say Presence(Any)
thwfhk Jun 30, 2023
91ae333
compatibility with old handler tests
thwfhk Jun 30, 2023
e9e3bf8
Merge branch 'cfl-linear-default' into control-flow-linearity
thwfhk Jun 30, 2023
c525c04
postpone something, but equivalent
thwfhk Jun 30, 2023
c9eba50
more printing compatibility
thwfhk Jul 1, 2023
b98378a
more tests
thwfhk Jul 1, 2023
5796f26
Merge remote-tracking branch 'upstream/control-flow-linearity' into c…
thwfhk Jul 1, 2023
2615823
add a readme
thwfhk Jul 1, 2023
7b9a8c2
update the syntax of presence variables
thwfhk Jul 5, 2023
ed2c26c
some backward compatibility
thwfhk Jul 5, 2023
6086c36
update the documentation
thwfhk Jul 6, 2023
0235d3e
typo
thwfhk Jul 6, 2023
dd43b18
Merge remote-tracking branch 'upstream/master' into control-flow-line…
thwfhk Jul 31, 2023
366aaaf
update document
thwfhk Sep 19, 2023
0d3c5b9
Fixed a stupid and hard-to-find bug about flattening effect types, wh…
thwfhk Sep 19, 2023
6b741ee
update the original handlers test
thwfhk Sep 19, 2023
5d5fa5e
update the original typecheck_examples test
thwfhk Sep 19, 2023
6d9c0fa
update tests and compatibility document
thwfhk Sep 19, 2023
6ba486d
update tests and compatibility document
thwfhk Sep 19, 2023
436bc16
trim trailing whitespaces
thwfhk Sep 19, 2023
f8e5218
remove some test comments
thwfhk Sep 19, 2023
29a0605
add more test cases on usage of linear resources in handlers
thwfhk Sep 21, 2023
55ab6c5
try to enable automatic xlin, but it seems to be not very useful
thwfhk Sep 21, 2023
3728cee
fix a testcase
thwfhk Sep 21, 2023
7202caa
add more CFL tests
thwfhk Sep 21, 2023
ee943ba
modify the type signatures of some library functions
thwfhk Sep 21, 2023
fc00331
fix a test case because APs are unlimited
thwfhk Sep 21, 2023
0f10124
give a more flexible type to the prelude function fork
thwfhk Sep 21, 2023
8336bf3
more tests
thwfhk Sep 22, 2023
29e7eec
remove a redundant line
thwfhk Sep 22, 2023
5413bca
more tests from the paper
thwfhk Sep 22, 2023
f17866c
remove a doc file
thwfhk Sep 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/basicsettings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ module Handlers = struct
|> sync)
end

(* control-flow linearity *)
module CTLinearity = struct
let enabled =
Settings.(flag "track_control_flow_linearity"
|> privilege `System
|> synopsis "Enables the control-flow linearity extension"
|> convert parse_bool
|> CLI.(add (long "track-control-flow-linearity"))
|> sync)
end

module Sessions = struct
let exceptions_enabled =
Settings.(flag "session_exceptions"
Expand Down
4 changes: 2 additions & 2 deletions core/commonTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ module Linearity = struct
| Unl -> true
| _ -> false

let to_string = function
let to_string ?(is_eff=false) = function
| Any -> "Any"
| Unl -> "Unl"
| Unl -> if is_eff then "Lin" else "Unl"

let min l r =
match l, r with
Expand Down
4 changes: 2 additions & 2 deletions core/compilePatterns.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let rec desugar_pattern : Types.row -> Sugartypes.Pattern.with_pos -> Pattern.t
| Variant (name, Some p) ->
let p, env = desugar_pattern p in
Pattern.Variant (name, p), env
| Operation (name, ps, k) ->
| Operation (name, ps, k, _) ->
let ps, env =
List.fold_right
(fun p (ps, env) ->
Expand Down Expand Up @@ -996,7 +996,7 @@ let compile_handle_cases
fields
in
let rec extract t = match TypeUtils.concrete_type t with
| Types.Operation (domain, _) ->
| Types.Operation (domain, _, _) ->
let (fields, _, _) = TypeUtils.extract_row domain |> TypeUtils.extract_row_parts in
let arity = StringMap.size fields in
if arity = 1 then
Expand Down
4 changes: 2 additions & 2 deletions core/desugarDatatypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ module Desugar = struct
| Record r -> Types.Record (row alias_env r t')
| Variant r -> Types.Variant (row alias_env r t')
| Effect r -> Types.Effect (row alias_env r t')
| Operation (f, t) -> Types.Operation ( Types.make_tuple_type (List.map datatype f)
, datatype t )
| Operation (f, t, b) -> Types.Operation ( Types.make_tuple_type (List.map datatype f)
, datatype t, b)
| Table (tmp, r, w, n) -> Types.Table (tmp, datatype r, datatype w, datatype n)
| List k -> Types.Application (Types.list, [(PrimaryKind.Type, datatype k)])
| TypeApplication (tycon, ts) ->
Expand Down
31 changes: 16 additions & 15 deletions core/desugarEffects.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ let simplify_tycon_env (tycon_env : Types.tycon_environment) : simple_tycon_env
in
SEnv.fold simplify_tycon tycon_env SEnv.empty

let make_anon_point k sk freedom =
let make_anon_point ?(is_eff=true) k sk freedom =
let var = Types.fresh_raw_variable () in
Unionfind.fresh
(Types.Var (var, (k, DesugarTypeVariables.concrete_subkind sk), freedom))
(Types.Var (var, (k, DesugarTypeVariables.concrete_subkind ~is_effect:is_eff sk), freedom))

(** A map with SugarTypeVar as keys, use for associating the former
with information about what
Expand Down Expand Up @@ -364,7 +364,8 @@ let cleanup_effects tycon_env =
WithPos.make ~pos (match node with
| Datatype.Operation _ -> node
| Datatype.Forall (qs, dt) -> Datatype.Forall (qs, elaborate_op dt)
| _ -> Datatype.Operation ([], dt))
| _ -> Datatype.Operation ([], dt, DeclaredLinearity.Unl))
(* nullary operations without =@ are unlimited *)
in
let fields = List.map (function
| name, Present dt when not (TypeUtils.is_builtin_effect name) ->
Expand All @@ -379,18 +380,18 @@ let cleanup_effects tycon_env =
if not (SugarTypeVar.is_resolved stv)
then begin
let gen_unresolved_eff () =
SugarTypeVar.mk_unresolved shared_effect_var_name None `Rigid
SugarTypeVar.mk_unresolved shared_effect_var_name ~is_eff:true None `Rigid
in
let to_unresolved_general sk fr =
SugarTypeVar.mk_unresolved "$" sk fr
SugarTypeVar.mk_unresolved "$" ~is_eff:true sk fr
in
let gen_resolved_flex () =
SugarTypeVar.mk_resolved_row
(let var = Types.fresh_raw_variable () in
Unionfind.fresh
(Types.Var (var, (PrimaryKind.Row, (lin_unl, res_effect)), `Flexible)))
(Types.Var (var, (PrimaryKind.Row, (default_effect_lin, res_effect)), `Flexible)))
in
let name, sk, fr = gue stv in
let name, (_, sk), fr = gue stv in
if has_effect_sugar
then
begin
Expand Down Expand Up @@ -453,7 +454,7 @@ let gather_mutual_info (tycon_env : simple_tycon_env) =
match eff_var with
| Datatype.Open stv
when (not (SugarTypeVar.is_resolved stv))
&& SugarTypeVar.get_unresolved_exn stv = ("$eff", None, `Rigid)
&& SugarTypeVar.get_unresolved_exn stv = ("$eff", (true, None), `Rigid)
->
self#with_implicit
| _ -> self )
Expand Down Expand Up @@ -768,7 +769,7 @@ let gather_operations (tycon_env : simple_tycon_env) allow_fresh dt =
let point =
lazy
(let var = Types.fresh_raw_variable () in
Unionfind.fresh (Types.Var (var, (PrimaryKind.Presence, default_subkind), `Rigid)))
Unionfind.fresh (Types.Var (var, (PrimaryKind.Presence, default_effect_subkind), `Rigid)))
in
StringMap.add op point m)
v StringMap.empty),
Expand All @@ -786,7 +787,7 @@ let preprocess_type (dt : Datatype.with_pos) tycon_env allow_fresh shared_effect
lazy
(let var = Types.fresh_raw_variable () in
Unionfind.fresh
(Types.Var (var, (PrimaryKind.Row, (lin_unl, res_any)), `Rigid)))
(Types.Var (var, (PrimaryKind.Row, default_effect_subkind), `Rigid)))
in
Some point
| _ ->
Expand Down Expand Up @@ -948,7 +949,7 @@ class main_traversal simple_tycon_env =
(* Looking for this gives us the operations associcated with
the $eff var. The kind and freedom info are ignored for the lookup *)
let eff_sugar_var =
SugarTypeVar.mk_unresolved shared_effect_var_name None
SugarTypeVar.mk_unresolved shared_effect_var_name ~is_eff:true None
`Rigid
in

Expand Down Expand Up @@ -1018,8 +1019,8 @@ class main_traversal simple_tycon_env =
if not allow_implictly_bound_vars then
raise (DesugarTypeVariables.free_type_variable dpos);

let _name, sk, freedom = SugarTypeVar.get_unresolved_exn stv in
let mtv = make_anon_point (PrimaryKind.Row) sk freedom in
let _name, (is_eff, sk), freedom = SugarTypeVar.get_unresolved_exn stv in
let mtv = make_anon_point ~is_eff:is_eff (PrimaryKind.Row) sk freedom in
let rtv = SugarTypeVar.mk_resolved_row mtv in
(o, D.Open rtv)
| D.Open srv when not (SugarTypeVar.is_resolved srv) ->
Expand Down Expand Up @@ -1177,7 +1178,7 @@ class main_traversal simple_tycon_env =
({ node = t, args, b; pos } as tn) =
if StringMap.find t implicits then
let var = Types.fresh_raw_variable () in
let q = (var, (PrimaryKind.Row, (lin_unl, res_effect))) in
let q = (var, (PrimaryKind.Row, (default_effect_lin, res_effect))) in
(* Add the new quantifier to the argument list and rebind. *)
(* let qs = List.map (snd ->- OptionUtils.val_of) args @ [q] in *)
let args = args @ [ SugarQuantifier.mk_resolved q ] in
Expand All @@ -1191,7 +1192,7 @@ class main_traversal simple_tycon_env =
let tycon_env = SEnv.bind t (env_args, true, None) tycon_env in
let shared_effect_var : Types.meta_row_var Lazy.t =
lazy
(Unionfind.fresh (Types.Var (var, (PrimaryKind.Row, (lin_unl, res_effect)), `Rigid)))
(Unionfind.fresh (Types.Var (var, (PrimaryKind.Row, (default_effect_lin, res_effect)), `Rigid)))
in
let shared_var_env =
StringMap.add t (Some shared_effect_var) shared_var_env
Expand Down
6 changes: 4 additions & 2 deletions core/desugarSessionExceptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ object (o : 'self_type)
let ty =
Types.fresh_type_variable (CommonTypes.lin_any, CommonTypes.res_any) in
let with_pos x = SourceCode.WithPos.make ~pos x in
let doOp = DoOperation (with_pos (Operation failure_op_name), [], Some (Types.empty_type)) in
(* FIXME: WT: I don't know whether should it be lindo or not *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets leave as-is for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though, I see that you have changed the signature of SessionFail below... I would be inclined not to change any of the session exceptions stuff.

Copy link
Contributor Author

@thwfhk thwfhk Jun 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to change the SessionFail operation to be linear to make the functions in prelude.links well-typed. Otherwise we would get a type error because we use the unlimited operation SessionFail with linear channels. I also need to change some signatures of functions in lib.ml, because by default e::Row is e::Row(Unl,Any), which can only be unified with linear operations.

This is also a challenge for hiding this feature behind a new flag; it is not entirely compatible with the current Links syntax.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see... The settings logic does allow you specify transitive dependencies, so if session exceptions are toggled, then you can forcibly toggle linear continuations too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is fine to not toggle control_flow_linearity, but we still need to make sure that the existing library code is compatible with it. FOr example, using unlimited row variable e::Row(Any, Any) by default and use the linear operation signature =@ for SessionFail.

let doOp = DoOperation (with_pos (Operation failure_op_name), [], Some (Types.empty_type), DeclaredLinearity.Lin) in
(o, with_pos (Switch (with_pos doOp, [], Some ty)), ty)
| { node = TryInOtherwise (_, _, _, _, None); _} -> assert false
| { node = TryInOtherwise (try_phr, pat, as_phr, otherwise_phr, (Some dt)); pos }
Expand Down Expand Up @@ -122,7 +123,8 @@ object (o : 'self_type)
(Utility.gensym ~prefix:"dsh" ()) in

let otherwise_pat : Sugartypes.Pattern.with_pos =
with_dummy_pos (Pattern.Operation (failure_op_name, [], cont_pat)) in
(* FIXME: WT: I don't know whether should it be lincase or not *)
thwfhk marked this conversation as resolved.
Show resolved Hide resolved
with_dummy_pos (Pattern.Operation (failure_op_name, [], cont_pat, DeclaredLinearity.Lin)) in

let otherwise_clause = (otherwise_pat, otherwise_phr) in

Expand Down
38 changes: 19 additions & 19 deletions core/desugarTypeVariables.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ let free_type_variable ?var pos =
"Unbound " ^ desc ^ " in position where
no free type variables are allowed")

let concrete_subkind =
let concrete_subkind ?(is_effect=false) =
function
| Some subkind -> subkind
| None -> default_subkind
| None -> if is_effect then default_effect_subkind else default_subkind


let default_kind : PrimaryKind.t = PrimaryKind.Type
Expand Down Expand Up @@ -169,36 +169,36 @@ However, this is not the same as setting defaults. Instead,
the info in the map takes precedence.

*)
let make_opt_kinded_var k sk_opt freedom : Types.t =
let make_opt_kinded_var k ?(is_eff=false) sk_opt freedom : Types.t =
let var = Types.fresh_raw_variable () in
let sk = concrete_subkind sk_opt in
let sk = concrete_subkind ~is_effect:is_eff sk_opt in
Types.Var (var, (k, sk), freedom)

let get_var_info (info : Types.t) =
match info with
| Types.Var (var, k, fd) -> (var, k, fd)
| _ -> raise found_non_var_meta_var

let make_fresh_entry pk_opt sk_opt freedom : tyvar_map_entry =
let make_fresh_entry pk_opt ?(is_eff=false) sk_opt freedom : tyvar_map_entry =
let open PrimaryKind in
match pk_opt with
| None -> TVUnkinded (sk_opt, freedom)
| Some Type ->
let point = Unionfind.fresh (make_opt_kinded_var Type sk_opt freedom) in
let point = Unionfind.fresh (make_opt_kinded_var ~is_eff:is_eff Type sk_opt freedom) in
TVType (sk_opt, point)
| Some Row ->
let point = Unionfind.fresh (make_opt_kinded_var Row sk_opt freedom) in
let point = Unionfind.fresh (make_opt_kinded_var ~is_eff:is_eff Row sk_opt freedom) in
TVRow (sk_opt, point)
| Some Presence ->
let point = Unionfind.fresh (make_opt_kinded_var Presence sk_opt freedom) in
let point = Unionfind.fresh (make_opt_kinded_var ~is_eff:is_eff Presence sk_opt freedom) in
TVPresence (sk_opt, point)



(* does not do all sanity checks *)
(* Note that this always reuses existing points! *)
let update_entry pk sk_opt freedom existing_entry : tyvar_map_entry =
let con_sk = concrete_subkind sk_opt in
let update_entry pk ?(is_eff=false) sk_opt freedom existing_entry : tyvar_map_entry =
let con_sk = concrete_subkind ~is_effect:is_eff sk_opt in
let open PrimaryKind in
match pk, existing_entry with
| _, TVUnkinded _ ->
Expand Down Expand Up @@ -290,7 +290,7 @@ object (o : 'self)


(** Used for type/row/presence variables found along the way, including anonymous ones *)
method add ?pos name (pk : PrimaryKind.t) (sk : Subkind.t option) freedom : 'self * SugarTypeVar.t =
method add ?pos name (pk : PrimaryKind.t) ?(is_eff=false) (sk : Subkind.t option) freedom : 'self * SugarTypeVar.t =
let anon = is_anonymous_name name in
let pos = OptionUtils.from_option SourceCode.Position.dummy pos in
if not anon && StringMap.mem name tyvar_map then
Expand All @@ -314,7 +314,7 @@ object (o : 'self)
the *existing* unionfind point carried inside the entry *)
let entry =
if pk' <> pk_union' || sk' <> sk_union' then
update_entry pk sk freedom existing_entry
update_entry pk ~is_eff:is_eff sk freedom existing_entry
else
existing_entry
in
Expand All @@ -332,7 +332,7 @@ object (o : 'self)
Since at this point we know the primary kind,
this will always result in the creation of a unionfind point.
*)
let entry = make_fresh_entry (Some pk) sk freedom in
let entry = make_fresh_entry (Some pk) ~is_eff:is_eff sk freedom in
let o =
if anon then o else o#bind name entry in
let resolved_var = resolved_var_of_entry entry in
Expand Down Expand Up @@ -390,8 +390,8 @@ object (o : 'self)
let open Datatype in
function
| TypeVar stv ->
let (name, sk, freedom) = SugarTypeVar.get_unresolved_exn stv in
let o, resolved_tv = o#add name pk_type sk freedom in
let (name, (is_eff, sk), freedom) = SugarTypeVar.get_unresolved_exn stv in
let o, resolved_tv = o#add name pk_type ~is_eff:is_eff sk freedom in
(* let resolved_tv = resolved_var_of_entry entry in *)
o, TypeVar resolved_tv
| Forall (unresolved_qs, body) ->
Expand Down Expand Up @@ -423,8 +423,8 @@ object (o : 'self)
appear in contexts where implictly scoped variables are allowed. *)
o, orig
| Open srv ->
let (name, sk, freedom) = SugarTypeVar.get_unresolved_exn srv in
let o, resolved_rv = o#add name pk_row sk freedom in
let (name, (is_eff, sk), freedom) = SugarTypeVar.get_unresolved_exn srv in
let o, resolved_rv = o#add name pk_row ~is_eff:is_eff sk freedom in
o, Datatype.Open resolved_rv
| Recursive (stv, r) ->
let original_o = o in
Expand All @@ -446,8 +446,8 @@ object (o : 'self)
let o, t = o#datatype t in
o, Present t
| Var utv ->
let (name, sk, freedom) = SugarTypeVar.get_unresolved_exn utv in
let o, resolved_pv = o#add name pk_presence sk freedom in
let (name, (is_eff, sk), freedom) = SugarTypeVar.get_unresolved_exn utv in
let o, resolved_pv = o#add name pk_presence ~is_eff:is_eff sk freedom in
o, Var resolved_pv

method! phrase p =
Expand Down
2 changes: 1 addition & 1 deletion core/desugarTypeVariables.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
val infer_kinds : bool Settings.setting

val concrete_subkind : CommonTypes.Subkind.t option -> CommonTypes.Subkind.t
val concrete_subkind : ?is_effect:bool -> CommonTypes.Subkind.t option -> CommonTypes.Subkind.t

val free_type_variable : ?var:string -> SourceCode.Position.t -> exn

Expand Down
2 changes: 1 addition & 1 deletion core/generalise.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let rec get_type_args : gen_kind -> TypeVarSet.t -> datatype -> type_arg list =
get_type_args kind (TypeVarSet.add_quantifiers qs bound_vars) t
(* Effect *)
| Effect row -> get_row_type_args kind bound_vars row
| Operation (f, t) ->
| Operation (f, t, _) ->
let from_gens = gt f
and to_gens = gt t in
from_gens @ to_gens
Expand Down
2 changes: 1 addition & 1 deletion core/instantiate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let instantiates : instantiation_maps -> (datatype -> datatype) * (row -> row) *
| Record row -> Record (instr row)
| Variant row -> Variant (instr row)
| Effect row -> Effect (instr row)
| Operation (f, t) -> Operation (inst f, inst t)
| Operation (f, t, b) -> Operation (inst f, inst t, b)
| Table (tmp, f, d, r) -> Table (tmp, inst f, inst d, inst r)
| ForAll (qs, t) ->
let remove_shadowed_quantifier tmap q =
Expand Down
7 changes: 4 additions & 3 deletions core/irCheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,12 @@ let eq_types occurrence : type_eq_context -> (Types.datatype * Types.datatype) -
| Effect r -> eq_rows (context, l, r)
| _ -> false
end
| Operation (lfrom, lto) ->
| Operation (lfrom, lto, llin) ->
begin match t2 with
| Operation (rfrom, rto) ->
| Operation (rfrom, rto, rlin) ->
eqt (context, lfrom, rfrom) &&
eqt (context, lto , rto )
eqt (context, lto , rto ) &&
llin = rlin
| _ -> false
end
(* Row *)
Expand Down
4 changes: 4 additions & 0 deletions core/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ let keywords = [
"delete_left", DELETE_LEFT;
"determined", DETERMINED;
"do" , DOOP;
"lindo" , LINDOOP;
"effectname", EFFECTNAME;
"else" , ELSE;
"escape" , ESCAPE;
Expand Down Expand Up @@ -163,6 +164,8 @@ let keywords = [
"with" , WITH;
(* SAND *)
"tablekeys" , TABLEKEYS;
(* Control-flow linearity *)
"xlin" , LINFLAG
]

exception LexicalError of (string * Lexing.position)
Expand Down Expand Up @@ -212,6 +215,7 @@ rule lex ctxt nl = parse
| "-@" { LOLLI }
| "~@" { SQUIGLOLLI }
| "=>" { FATRARROW }
| "=@" { FATLOLLI }
| "-." { MINUSDOT }
| '-' { MINUS }
| '(' { LPAREN }
Expand Down
Loading
Loading