DEV Community

Discussion on: Interoperability with non functional code using fp-ts

Collapse
 
area73 profile image
Rodrigo

Ciao Giulio, I'm now starting to play with your awesome library and there are a couple of things that I just don't get it right , probably because of my poor knowledge in FP.

The first think that surprise me is how to implement the pipe function, for other libraries that I used before pie was defined like:
pipe :: ((a -> b), ..., (y -> z)) -> a -> z

So as an example I'm use to do something like:

const process = pipe(
map(toUpperCase),
map(removeVocals),
map(countChar)
);
Enter fullscreen mode Exit fullscreen mode

And then later pass my data type (IO, Option or any functor) to evaluate the result


const result = process(customOption)  

Enter fullscreen mode Exit fullscreen mode

but in your library you define it like:
pipe :: (a, (a -> b), ..., (y -> z)) -> z

so I don't see the way to get partially apply in order to do lazy evaluation and I also have to pass the data type as a first argument witch is really strange for me to be in a pipe.

Can you point me to the right direction?

Collapse
 
gcanti profile image
Giulio Canti

see flow gcanti.github.io/fp-ts/modules/fun...

  • pipe: pipes the value of an expression into a pipeline of functions
  • flow: performs left-to-right function composition