Add fromReaderEither and fromReaderTaskEither#33
Add fromReaderEither and fromReaderTaskEither#33konker wants to merge 1 commit intomaasglobal:mainfrom
Conversation
|
Originally, I wrote ruins so people who don't want to learn functional programming could work with a functional API without having to learn new things. Writing Let's now consider how the same example would work with If this seems like worth doing, and if we decided to go with non-curried implementation, then it would perhaps make sense to have deps as second argument. I would imagine that deps would more typically be the second argument in this kind of calls, since that might make using some default parameter solutions easier. |
|
For a moment I thought we could perhaps create overloads to make the dependencies optional in situations where they have some trivial type like This would work better in the curried form since we could necessitate a specific kind of Reader through the initial call. However, at this point it becomes a question of whether we want a more powerful FP-esque implementation, or a more procedural less powerful one. |
|
Technically it would be possible to also implement "kontra position" versions of these and all other tools already present in the ruins package. For example If we had such I was hoping we could use such kontra position variants in their point-free form. However, TypeScript seems to have some short comings in how it deals with typings of point-free functions. I think it is somehow related to how the official ResultType utility type does not take into account generics and overloads. See gcanti/fp-ts#1769 Also, kontra position variants feel a bit more advanced in general than the other utils we have so far included in the package. It is tempting to add all kinds of powerful bells and whistles but I am wondering how far we can stretch the feature set before this becomes an advanced utility library rather than a newbie survival kit. |
The use-case is for jest tests.
E.g.
Or possibly:
can become:
Although, maybe it's better to look at this:
https://github.com/relmify/jest-fp-ts
NOTE: if this is accepted, need to add new functions to README