I hadn’t thought about the fact that higher-order functions must have a different name if they take an effectful function than if they don’t, since effectful functions have different type signatures. Given this, will there be effectful versions of all higher-order functions in the builtins?
For example, the current builtins documentation has a List.walk! but not a List.map!, even though the example code for List.walk! would be simpler as List.map!.
will there be effectful versions of all higher-order functions in the builtins?
I think the plan was to provide effectful versions on an as needed basis. We've talked about List.map!
before, let me see if I can find that.
Alright. Obviously you can always use walk! to achieve what you would do with map!. It’s just a tradeoff between more clutter in the builtins vs slightly more complicated code.
I don’t see anything at that link that talks about whether to have a List.map!, but I take it people concluded walk! and for_each! were enough.
EDIT: Oh I see, List.map! is mentioned earlier.
It’s just a tradeoff between more clutter in the builtins vs slightly more complicated code.
Yeah, we always prefer "feature" discussion based on specific needs instead of hypothetical needs. List.map!
could make sense though!
I do find it slightly amusing that the documentation for List.walk! itself provides a good use case for List.map!. Of course that might not come up too often in practice.
Yeah, examples can be artificial because their goal is simply to be a nice demonstration
Last updated: Jul 06 2025 at 12:14 UTC