Skip to content

Commit

Permalink
hygienic references to library functions in pattern compilation (fix l…
Browse files Browse the repository at this point in the history
…inks-lang#24) (links-lang#843)

* hygienic references to library functions in pattern compilation

* removed commented out dead code
  • Loading branch information
jamescheney authored and frank-emrich committed Sep 16, 2020
1 parent 9054759 commit e6d1dfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
20 changes: 5 additions & 15 deletions core/compilePatterns.ml
Original file line number Diff line number Diff line change
Expand Up @@ -183,31 +183,26 @@ sig
end
=
struct
(* let lookup_type var (_nenv, tenv, _eff) = *)
(* TEnv.lookup tenv var *)

let lookup_name name (nenv, _tenv, _eff) =
NEnv.find name nenv

let lookup_effects (_nenv, _tenv, eff) = eff

let nil env t : value =
TApp (Variable (lookup_name "Nil" env),
let nil _env t : value =
TApp (Variable (NEnv.find "Nil" Lib.nenv),
[`Type t])

let list_head env t : value -> tail_computation = fun v ->
let eff = lookup_effects env in
Apply
(TApp
(Variable (lookup_name "hd" env),
(Variable (NEnv.find "hd" Lib.nenv),
[`Type t; `Row eff]),
[v])

let list_tail env t : value -> tail_computation = fun v ->
let eff = lookup_effects env in
Apply
(TApp
(Variable (lookup_name "tl" env),
(Variable (NEnv.find "tl" Lib.nenv),
[`Type t; `Row eff]),
[v])
end
Expand All @@ -219,19 +214,14 @@ sig
end
=
struct
(* let lookup_type var (_nenv, tenv, _eff) = *)
(* TEnv.lookup tenv var *)

let lookup_name name (nenv, _tenv, _eff) =
NEnv.find name nenv

let lookup_effects (_nenv, _tenv, eff) = eff

let eq env t : value -> value -> value = fun v1 v2 ->
let eff = lookup_effects env in
ApplyPure
(TApp
(Variable (lookup_name "==" env),
(Variable (NEnv.find "==" Lib.nenv),
[`Type t; `Row eff]),
[v1; v2])
end
Expand Down
1 change: 0 additions & 1 deletion tests/collections.tests
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ stdout : 2 : Int
Case patterns (with redefined hd)
{ fun hd(_) { 1 } switch (['a']) { case [y] -> y }}
stdout : 'a' : Char
ignore : Known hygiene problem

With parentheses:
switch ([1]) { case (x::xs) -> 1 case x -> 2 }
Expand Down

0 comments on commit e6d1dfa

Please sign in to comment.