swarm-game / swarm

Resource gathering + programming game
Other
820 stars 51 forks source link

Built-in function composition operator #1904

Open byorgey opened 1 month ago

byorgey commented 1 month ago

Is your feature request related to a problem? Please describe. Like a good functional programmer, I've been using function composition but just defining my own def compose : (b -> c) -> (a -> b) -> (a -> c). But it would be so much nicer if it was an infix operator.

Describe the solution you'd like I'd like to have a built-in function composition operator. It can require the same capability as using functions in general (i.e. CLambda) and hence provided by an equipped lambda entity. Since it's already possible to define your own once you can use lambdas, I don't think it makes sense to make a separate capability for it.

Using . as the syntax (as in Haskell) would be nice, and I think it should not introduce any ambiguity (we do use . several other places in the grammar already - after a forall and after a lambda - but they occur in different, clearly distinguished contexts). But I am not wedded to that particular syntax.

byorgey commented 1 month ago

If you followed the link here from the Haskell Weekly News, welcome! I'd be very happy to point potential contributors to the relevant places in the codebase, answer any questions you might have, etc - just leave a comment here.