I’m trying to start implementing the list module in leema tonight, and particularly the map function in the list module. It’s not hard, I’m using the naïve approach to recurse through the list while calling the function for each item.
func map(items: [$A], f): [$B] -> map(, items, f) -- func _map(result: [$B], input: [$A], f): [$B] |(result, , _f) -> reverse(result) |(result, h;t, f) -> _map(f(h);result, t, f) --
This is all going great until I realize I haven’t yet implemented the syntax for a function type. There isn’t one obvious choice, so here are two options I’m considering. Examples are given for a function that takes an integer and a boolean and returns a string.
F(Int, Bool): Str Int > Bool > Str
The first example is most like the leema function declaration syntax. It’s also more similar to Rust and even a little like Go. The second is definitely inspired by Haskell. I’m kind of partial to the latter, but I think the former will be more practical particularly in the case that it ever makes sense to add named parameters. Do you have a favorite?