crocks icon indicating copy to clipboard operation
crocks copied to clipboard

Allow ReaderT to work with Fluture

Open svozza opened this issue 5 years ago • 4 comments

Is your feature request related to a problem? Please describe. It would be nice to be able to use the Fluture async library to work with the ReaderT monad.

Describe the solution you'd like Seamless use the Fluture type.

Describe alternatives for how you do this now I'm using the Async type.

Code

const C = require('crocks');
const Future = require('fluture');
const {ReaderT} = C;

const ReaderFuture = ReaderT(Future)

ReaderFuture.ask()
    .runWith()
    .fork(e => e, x => x);

This currently results in the following exception:

/Users/svozza/git/github.com/svozza/crocks-test/node_modules/crocks/Reader/ReaderT.js:23
    function () { return (_type + "( " + (Monad.type()) + " )"); }
                                                ^

TypeError: Monad.type is not a function
    at type (/Users/svozza/git/github.com/svozza/crocks-test/node_modules/crocks/Reader/ReaderT.js:23:49)
    at ReaderT (/Users/svozza/git/github.com/svozza/crocks-test/node_modules/crocks/Reader/ReaderT.js:71:29)
    at Function.ask (/Users/svozza/git/github.com/svozza/crocks-test/node_modules/crocks/Reader/ReaderT.js:33:14)
    at Object.<anonymous> (/Users/svozza/git/github.com/svozza/crocks-test/fluture.js:7:14)
    at Module._compile (internal/modules/cjs/loader.js:1085:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:791:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

svozza avatar Oct 30 '20 18:10 svozza

Just as an initial thought, could you write something in your local codebase that modifies the prototype of Future or you could wrap it if you wanted?

dalefrancis88 avatar Oct 30 '20 18:10 dalefrancis88

Sure, but the whole point of the Fantasyland spec was to make all these types interoperable.

svozza avatar Oct 31 '20 12:10 svozza

Sorry it's my bad, I hadn't seen the conversation on gitter so didn't have the context. The above comment was not to say that it won't be done but more to help you get through your immediate need why you waited for the change to be committed

dalefrancis88 avatar Oct 31 '20 16:10 dalefrancis88

Ah sorry, I phrased that a bit blunter than I should have! I get what ya mean.

svozza avatar Oct 31 '20 16:10 svozza