Skip to content

Flip around order of arguments #51

Description

@masaeedu

Thank you for a very useful library. It's a bit late to bring this up I think, but I thought I'd open an issue anyway; it seems like the current order of arguments is not great for partial application. From the README examples:

const compress = (numbers) => {
  return matches(numbers)(
    (x, y, xs) => x === y
      ? compress([x].concat(xs))
      : [x].concat(compress([y].concat(xs))),
    (x, xs) => x // stopping condition
  )
}

but if it accepted the case matchers first, it could just be:

const compress = matches(
  (x, y, xs) => x === y
    ? compress([x].concat(xs))
    : [x].concat(compress([y].concat(xs))),
  (x, xs) => x // stopping condition
)

It's not hard to define a flipped around version wherever I use it, but it'd be handy if the library just exported a different version of matches that took arguments in that order.

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions