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

Generative labels #1169

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
b1969a3
effectalias init
Orbion-J May 13, 2022
49a9a61
desalias inline
Orbion-J May 13, 2022
36a488f
alias = effectname and typename | init
Orbion-J May 18, 2022
dbb6b5b
merge into 1 construct ok; still 2 contexts
Orbion-J May 19, 2022
84ffd9b
merge type and effect aliases contexts
Orbion-J May 20, 2022
5150615
effectname body desugared into effectname
Orbion-J May 20, 2022
ee1651e
Merge branch 'merge-typenames-effectnames'
Orbion-J May 20, 2022
a2d8bdc
Revert "desalias inline"
Orbion-J May 23, 2022
419aca4
Revert "effectname body desugared into effectname"
Orbion-J May 23, 2022
6e8c0df
"effectname" in links-mode.el
Orbion-J May 24, 2022
1355a93
cleaning before pr
Orbion-J May 24, 2022
50edb64
re-cleaning
Orbion-J May 24, 2022
ce200de
effectname -> typename _::Kind
Orbion-J May 27, 2022
c0c3e5b
Update bin/repl.ml
Orbion-J May 27, 2022
eace411
Update bin/repl.ml
Orbion-J May 27, 2022
93b2cf1
Update bin/repl.ml
Orbion-J May 27, 2022
1736097
Update bin/repl.ml
Orbion-J May 27, 2022
bb0fb30
Update bin/repl.ml
Orbion-J May 27, 2022
6206a6b
Update core/desugarDatatypes.mli
Orbion-J May 27, 2022
9a499fc
Update bin/repl.ml
Orbion-J May 27, 2022
c45fbbc
Update core/defaultAliases.ml
Orbion-J May 27, 2022
832a424
Update core/desugarDatatypes.ml
Orbion-J May 27, 2022
0bd30cd
Update core/desugarDatatypes.ml
Orbion-J May 27, 2022
35e50e8
Update core/desugarDatatypes.ml
Orbion-J May 27, 2022
14df529
rename alias_env -> tycon_env as originally
Orbion-J May 27, 2022
31dffbb
Merge branch 'master' of github.com:Orbion-J/links
Orbion-J May 27, 2022
3489b8a
idem
Orbion-J May 27, 2022
b35a3da
fixes & add primary kind in aliases
Orbion-J May 30, 2022
69f2920
new error kind mismatch
Orbion-J Jun 1, 2022
f88808d
fresh label : init
Orbion-J Jun 3, 2022
5bce834
local labels : working
Orbion-J Jun 13, 2022
dccac21
fix : embeded errors
Orbion-J Jun 13, 2022
fd82138
fixes
Orbion-J Jun 14, 2022
806570a
fix label projections
Orbion-J Jun 14, 2022
7dc5f76
fix : underscore in effect app
Orbion-J Jun 15, 2022
ca580a5
various fixes
Orbion-J Jun 15, 2022
e118c0e
short type in effectname + short fun non desugar
Orbion-J Jun 16, 2022
109ca66
comment
Orbion-J Jun 16, 2022
0ab606c
Merge branch 'master' into master
Orbion-J Jun 16, 2022
dc0682f
always desugar op type with type application
Orbion-J Jun 16, 2022
01d9a09
correction tests
Orbion-J Jun 16, 2022
56ac19b
erase local labels out of scope (err when nested)
Orbion-J Jun 20, 2022
7a9a437
nested fresh label
Orbion-J Jun 22, 2022
4b6d3f9
fix stack overflow w/ points + clean debug
Orbion-J Jun 22, 2022
fd52e08
alias stuff
Orbion-J Jun 23, 2022
aa73727
functional
Orbion-J Jun 24, 2022
99c0878
remove wrong UnboundTyCon error
Orbion-J Jun 24, 2022
07040be
Merge branch 'links-lang:master' into master
Orbion-J Jun 24, 2022
6d907e7
default arg in repl
Orbion-J Jun 24, 2022
75a4f73
Merge branch 'master' of github.com:Orbion-J/links
Orbion-J Jun 24, 2022
82641fc
alias stuff + context management
Orbion-J Jun 24, 2022
b9e25e6
wip
Orbion-J Jun 27, 2022
571ffa2
Merge branch 'master' into fresh-label
Orbion-J Jun 27, 2022
c76a41e
Merge branch 'links-lang:master' into fresh-label
Orbion-J Jun 27, 2022
38f7f3e
fold_left_map in ListUtils (not in Ocaml < 4.11)
Orbion-J Jun 27, 2022
58919f5
Merge branch 'fresh-label' of github.com:Orbion-J/links into fresh-label
Orbion-J Jun 27, 2022
6a5e7da
fix in test
Orbion-J Jun 27, 2022
310ebb4
fixes rule-check ocamlformat
Orbion-J Jun 27, 2022
152b59a
fixes rule-check ocamlformat bis
Orbion-J Jun 27, 2022
de09626
fix tests unit labels
Orbion-J Jun 27, 2022
667a886
fix Labels in tests
Orbion-J Jun 28, 2022
61ad662
fix Labels tests
Orbion-J Jun 28, 2022
589a7db
fix labels tests
Orbion-J Jun 28, 2022
3ea8ddf
fix labels tests
Orbion-J Jun 28, 2022
ab3ab86
fix labels tests
Orbion-J Jun 28, 2022
5e5dae6
change pollution test
Orbion-J Jul 22, 2022
d31a6fe
Merge branch 'fresh-label' of github.com:Orbion-J/links into Orbion-J…
dhil Jan 31, 2023
066af32
Refactor
dhil Jan 31, 2023
478c2a2
Fix bug and generalise.
dhil Jan 31, 2023
717eba0
Fix unique label resolution
dhil Jan 31, 2023
ec92181
Fix session exceptions regression
dhil Jan 31, 2023
192c437
Slight hack to make unique labels work properly with elaborated modules.
dhil Jan 31, 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
2 changes: 1 addition & 1 deletion bin/repl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ let rec directives : (string * ((Context.t -> string list -> Context.t) * string
else (Module_hacks.Name.prettify name)
in
Printf.fprintf stderr " %-16s : %s\n"
name ty)
name ty) (* TODO(dhil): should really "prettify" ty here too as it may contain unique labels that have been expanded. *)
nenv ();
context),
"display the current value environment");
Expand Down
2 changes: 1 addition & 1 deletion core/buildTables.ml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ struct

let bindings tyenv bound_vars cont_vars bs =
let o = new visitor tyenv bound_vars cont_vars in
let _ = o#computation (bs, Return (Extend (StringMap.empty, None))) in ()
let _ = o#computation (bs, Return (Extend (Label.Map.empty, None))) in ()

let program tyenv bound_vars cont_vars e =
let _ = (new visitor tyenv bound_vars cont_vars)#computation e in ()
Expand Down
14 changes: 7 additions & 7 deletions core/channelVarUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ let variables_in_computation comp =
let variable_set = ref IntSet.empty in
let add_variable var =
variable_set := (IntSet.add var !variable_set) in
let rec traverse_stringmap : 'a . ('a -> unit) -> 'a stringmap -> unit =
let rec traverse_name_map : 'a . ('a -> unit) -> 'a name_map -> unit =
fun proj_fn smap -> (* (proj_fn: 'a . 'a -> 'b) (smap: 'a stringmap) : unit = *)
StringMap.fold (fun _ v _ -> proj_fn v) smap ()
Label.Map.fold (fun _ v _ -> proj_fn v) smap ()
and traverse_value = function
| Variable v -> add_variable v
| Closure (_, _, value)
Expand All @@ -24,13 +24,13 @@ let variables_in_computation comp =
| Coerce (value, _)
| Erase (_, value) -> traverse_value value
| XmlNode (_, v_map, vs) ->
traverse_stringmap (traverse_value) v_map;
traverse_name_map (traverse_value) v_map;
List.iter traverse_value vs
| ApplyPure (v, vs) ->
traverse_value v;
List.iter traverse_value vs
| Extend (v_map, v_opt) ->
traverse_stringmap (traverse_value) v_map;
traverse_name_map (traverse_value) v_map;
begin match v_opt with | Some v -> traverse_value v | None -> () end
| Constant _ -> ()
and traverse_tail_computation = function
Expand All @@ -42,7 +42,7 @@ let variables_in_computation comp =
traverse_value v; List.iter traverse_computation [c1 ; c2]
| Case (scrutinee, cases, case_opt) ->
traverse_value scrutinee;
traverse_stringmap (fun (_, c) -> traverse_computation c) cases;
traverse_name_map (fun (_, c) -> traverse_computation c) cases;
OptionUtils.opt_iter (fun (_, c) -> traverse_computation c) case_opt
and traverse_fundef {fn_binder = bnd; _} =
let fun_var = Var.var_of_binder bnd in
Expand Down Expand Up @@ -109,7 +109,7 @@ let variables_in_computation comp =
| DoOperation (_, vs, _) -> List.iter (traverse_value) vs
| Choice (v, clauses) ->
traverse_value v;
traverse_stringmap (fun (_, c) ->
traverse_name_map (fun (_, c) ->
traverse_computation c) clauses
| Lens (value, _)
| LensSerial { lens = value; _ }
Expand All @@ -124,7 +124,7 @@ let variables_in_computation comp =
and traverse_clause (_, _, c) = traverse_computation c
and traverse_handler (h: Ir.handler) =
traverse_computation (h.ih_comp);
traverse_stringmap (traverse_clause) h.ih_cases;
traverse_name_map (traverse_clause) h.ih_cases;
traverse_computation (snd h.ih_return)
in
traverse_computation comp;
Expand Down
24 changes: 12 additions & 12 deletions core/closures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ struct
let close f zs tyargs =
Closure (f, tyargs, Extend (List.fold_right
(fun (zname, zv) fields ->
StringMap.add zname zv fields)
Label.Map.add zname zv fields)
zs
StringMap.empty, None))
Label.Map.empty, None))

class visitor tenv fenv =
object (o : 'self) inherit IrTraversals.Transform.visitor(tenv) as super
Expand All @@ -456,7 +456,7 @@ struct
if IntSet.mem x cvars then
(* We cannot return t as the type of the result here. If x refers to a hoisted function that was generalised, then
t has additional quantifiers that are not present in the corresponding type of projecting x from parent_env *)
let projected_t = TypeUtils.project_type (string_of_int x) (thd3 (o#var parent_env)) in
let projected_t = TypeUtils.project_type (Label.of_int x) (thd3 (o#var parent_env)) in
Project (string_of_int x, Variable parent_env), projected_t
else if IntMap.mem x fenv then
let zs = (IntMap.find x fenv).termvars in
Expand All @@ -476,7 +476,7 @@ struct
(fun b ->
let z = Var.var_of_binder b in
let v = fst (var_val z) in
(string_of_int z, v))
(Label.of_int z, v))
zs
in
close x zs tyargs, overall_type
Expand Down Expand Up @@ -534,14 +534,14 @@ struct
| [], [] -> o, None
| _ ->
let zt =
Types.make_record_type
Types.(make_record_type
(List.fold_left
(fun fields b ->
let x = Var.var_of_binder b in
let xt = Var.type_of_binder b in
StringMap.add (string_of_int x) xt fields)
StringMap.empty
zs)
Label.Map.add (Label.of_int x) xt fields)
Label.Map.empty
zs))
in
(* fresh variable for the closure environment *)
let zb = Var.(fresh_binder (make_local_info (zt, "env_" ^ string_of_int f))) in
Expand Down Expand Up @@ -610,14 +610,14 @@ struct
| [], [] -> o, None
| _ ->
let zt =
Types.make_record_type
Types.(make_record_type
(List.fold_left
(fun fields b ->
let x = Var.var_of_binder b in
let xt = Var.type_of_binder b in
StringMap.add (string_of_int x) xt fields)
StringMap.empty
zs)
Label.Map.add (Label.of_int x) xt fields)
Label.Map.empty
zs))
in
(* fresh variable for the closure environment *)
let zb = Var.(fresh_binder (make_local_info (zt, "env_" ^ string_of_int f))) in
Expand Down
5 changes: 0 additions & 5 deletions core/commonTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,6 @@ module Name = struct
[@@deriving show]
end

module Label = struct
type t = string
[@@deriving show]
end

module ForeignLanguage = struct
type t =
| JavaScript
Expand Down
Loading