Remove dynamic bindings from strawman

Instead, I'm going to eventually try adding impredicativity with Quick
Look, so I can use records as modules and use one to pass effectful
library funcs to the entry point.
This commit is contained in:
Brandon Dyck 2023-08-15 21:42:04 -06:00
parent 96ee9c4307
commit 43fcb615fb

View File

@ -1,6 +1,3 @@
# v5
# Added implicit (dynamic) bindings
# v4
# Moved type annotations into bindings.
# Added def keyword for top-level bindings.
@ -33,8 +30,6 @@ type alias tree 'a = recurse 'T in <leaf, branch: {left: 'T, value: 'a, right: '
type alias maybe 'a = <some: 'a, nothing>
type alias unit = {}
implicit print(s: string) -> unit
# Type aliases should appear in compiler messages.
# binary_tree takes a comparison function and returns a record (like a JS
# object) as a module for handling binary trees of values of the same type
@ -43,7 +38,7 @@ def binary_tree(compare: fn('a) -> 'a) -> {
empty: tree 'a,
insert: fn(tree 'a, 'a) -> tree 'a,
find: fn(tree 'a, 'a) -> maybe 'a,
@"func we don't care about": fn() -> |print| unit
@"func we don't care about": fn() -> unit
} =
# A let expression can bind multiple names. Functions have access to all names within the expression,
# while other values only have access to names bound before them.
@ -70,7 +65,7 @@ def binary_tree(compare: fn('a) -> 'a) -> {
in {empty, insert, find, @"func we don't care about"}
# Prints "`some(2)".
def do_tree_things() -> |print| unit =
def do_tree_things() =
# Assume that int_compare is in the stdlib or something.
let {insert, empty, find | @"stuff we don't need"} = binary_tree(int_compare)
# I invented this fancy partial-application syntax with _, and then found
@ -81,7 +76,7 @@ def do_tree_things() -> |print| unit =
@"stuff we don't need"
# Prints "`some(2)\nignore me".
def main() = with print = native_print in do_tree_things().@"func we don't care about"()
def main() = do_tree_things().@"func we don't care about"()
def annotate(note: 'a, obj: {|'b}) -> {note: 'a | 'b} =
{ note | obj }