purescript-node/purescript-node-fs

Extract callback type, make monad instance?

Closed this issue · 11 comments

Since doing async using callbacks is the de facto in node land, I was wondering if it was time to extract the type Callback into it's own module, slap a monad instance onto it or integrate it easily with purescript-aff or contT? It would be great to get something like the aff monad just "out of the box" without some guff like this in order to write "nice looking" async code.

I'd probably build a separate library on top of this to provide the actions via Aff actually, as then people have the choice.

I'm all for an Aff version of these things though, I'd certainly prefer to use that formulation myself. If you want to go ahead and work on something like purescript-node-fs-aff I'd be happy to accept it into the organization.

I hear you, we could also have a promise based wrapper. It would be arbitrary to choose one. I will throw together such a library, shouldn't be more than a hundred lines of boilerplate code, really.

@garyb I have made start on this: felixSchl/purescript-node-fs-aff. It's a very thin wrapper around all async methods. Feedback very welcome. I had to muck around with Node.FS.Async.exists because it's callback-handler is missing the FS effect from it's signature, causing occurs check fails errors when compiling. I will hand in a PR to fix that when I get around to it.

I have now explicitly annotated the exported types and did a copy and paste job on the comments. If that's a problem, I don't mind rephrasing.

No, that's great if they still make sense!

I've invited you to the org so you should have permission to move the repository over if you want to do that. If you'd rather keep it under your own name, that's fine too. Thanks for working on this. 👍

Cool, thanks for the invitation, I have moved it over to the organisation now.

@garyb Could I get write access to the repo or do we have to go through the PR for each change? I have added an example, some docs and updated the gulpfile.

If you still have issues when you try next time, perhaps delete your local git repo and checkout again.

I checked the settings for the organization and the fs-aff team has no repositories assigned to it, could you assign purescript-node-fs-aff to the team?

That's done now. Strange that it didn't put it there by default!

Cheers :)