by plainOldText · 1y ago · 0 comments
Looking at their code however, I'm realizing one thing Elixir got "right", in my view, is the order of arguments in function calls.
For example, in Elixir to retrieve the value associated with a key in a map, you would write Map.get(map, key) or Map.get(map, key, default).
This feels so natural, particularly when you chain the operations using the pipe operator (|>):
map
|> Map.put(key, value)
|> Map.get(key)
In Flix it seems one needs to write Map.get(x, map), Map.insert(x, y, map). I guess it follows in the footsteps of F#. def main(): Unit \ IO =
Map.empty() |>
Map.insert("Hello", "World") |>
Map.get("Hello") |>
println
So I am not sure what you mean? In general, if you like pipelines then you want the "subject" (here the map) to be the last argument. That is how it is in Flix.Subject First:
Map.put(map, key, value)
Map.get(map, key)
Map.get(map, key, default)
Map.del(map, key)
Subject Last: Map.put(key, value, map)
Map.get(key, map)
Map.get(key, default, map)
Map.del(key, map)