Skip to content

Built-in function composition operator #1904

Open
@byorgey

Description

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.

Metadata

Assignees

No one assigned

    Labels

    C-Low Hanging FruitIdeal issue for new contributors.L-CommandsBuilt-in commands (e.g. move, try, if, ...) in the Swarm language.L-ParsingParsing the Swarm language from a string into an AST.S-Nice to haveThe bug fix or feature would be nice but doesn't currently have much negative impact.Z-FeatureA new feature to be added to the game.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions