DEV Community

Discussion on: Pipeable Pattern Matching in Typescript

skona27 profile image
Jakub Skoneczny

I don't quite get this part:

const optionMatching = (o: O.Option<string>) =>
      Some: ({ value }) => 'Something: ' + value,
      None: () => 'Nothing',
Enter fullscreen mode Exit fullscreen mode

Why do we pass o through a pipe? It is not a function because later in assertion, we provide a O.some('data') as a parameter for optionMathing.

stefano_regosa profile image
Stefano Regosa Author

you are right in fact it isn't !!!
if we look at the fp-ts pipe signature and all the types overload ... the first params is a Generic and doesn't have to be a function :

for this reason, we can pass the Option as the first argument and then pipe its model inside the M.matchW('_tag')