summaryrefslogtreecommitdiff
path: root/src/initial_check.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2017-06-28 19:35:57 +0100
committerAlasdair Armstrong2017-06-28 19:35:57 +0100
commit7a20fdcb37a1e7ac0f86d455c616d0a39d9d92bd (patch)
treeb896676d09178f4f3a2447d431373f687ba6a2a2 /src/initial_check.ml
parent32a621d568081cc7f60102d35d84bece9bbd01c5 (diff)
User defined overloaded operators
New typechecker has no builtin overloaded operators - instead can now write something in SAIL like: overload (deinfix +) [id1; id2; id3] to set up functions id1, id2, and id3 as overloadings for the + operator. Any identifier can be overloaded, not just infix ones. This is done in a backwards compatible way, so the old typechecker removes the DEF_overload nodes from the ast so the various backends never see it.
Diffstat (limited to 'src/initial_check.ml')
-rw-r--r--src/initial_check.ml2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/initial_check.ml b/src/initial_check.ml
index 8ee3da1b..b6d4f863 100644
--- a/src/initial_check.ml
+++ b/src/initial_check.ml
@@ -847,6 +847,8 @@ let to_ast_dec (names,k_env,def_ord) (Parse_ast.DEC_aux(regdec,l)) =
let to_ast_def (names, k_env, def_ord) partial_defs def : def_progress envs_out * (id * partial_def) list =
let envs = (names,k_env,def_ord) in
match def with
+ | Parse_ast.DEF_overload(id,ids) ->
+ ((Finished(DEF_overload(to_ast_id id, List.map to_ast_id ids))),envs),partial_defs
| Parse_ast.DEF_kind(k_def) ->
let kd,envs = to_ast_kdef envs k_def in
((Finished(DEF_kind(kd))),envs),partial_defs