unsplash/sum-types

Match constant

samhh opened this issue · 1 comments

samhh commented

The following is quite common, particularly for nullary sums:

Sum.match({
  // Or lambdas, similar verbosity.
  Foo: constant('foo'),
  Bar: constant('bar'),
  Baz: constant('baz'),
})

We could add match/matchW variants that don't provide access to member values:

Sum.matchConstantButPleaseRenameMe({
  Foo: 'foo',
  Bar: 'bar',
  Baz: 'baz',
})
samhh commented

matchX - "X" like "strict".