Skip to content

Make higher-order flows implicitly thread arguments #113

@rvs314

Description

@rvs314

I find myself often writing flows that look like this:

(define-flow part-2
  (~> parse
      (>< (~> △ append))
      ▽ (split-into 3) △
      (>< (~> △ set-intersect car score))
      (<< +)))

That is, code which uses a higher-order flow like ><, which then immediately takes a ~> form. A small regex search shows that the majority of the code which uses >< in a personal project immediately takes a ~> form. Given that >< is a unary operator, it would be convenient if it and a few other operators could take an arbitrary number of arguments, then passes them to ~>. It wouldn't be a breaking change, as (>< X) would still parse as it does normally.

I think the following could be made variadic:

  • ><
  • pass
  • clos
  • all
  • any
  • none
  • not
  • gate

If others think this change would be useful, I'd be happy to send a PR which implements it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions