pfgray / ts-adt

Generate Algebraic Data Types and pattern matchers
MIT License
314 stars 13 forks source link

change _type to _tag #6

Closed broerjuang closed 3 years ago

broerjuang commented 3 years ago

I use this package side-by-side by fp-ts and under the hood fp-ts is using _tag as type signature. See this.

pfgray commented 3 years ago

Yeah, I think it would be nice to be able to use this easily with fp-ts types... I have tried making a generalized version, but it completely removes inference:

const matchTag = makeMatch('_tag')

pipe(
  O.fromNullable(...),
  matchTag({
    Some: () => ...,
    None: () => ...
  })
)

I think this is the better route, but not sure if the inference is workable.

pfgray commented 3 years ago

We're gonna target v2(https://github.com/pfgray/ts-adt/issues/8) for this feature