purescript-node / purescript-node-fs

Node.js file I/O for purescript
MIT License
33 stars 34 forks source link

Extract callback type, make monad instance? #17

Closed felixSchl closed 9 years ago

felixSchl commented 9 years ago

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.

garyb commented 9 years ago

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.

felixSchl commented 9 years ago

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.

felixSchl commented 9 years ago

@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.

felixSchl commented 9 years ago

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.

garyb commented 9 years ago

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. :thumbsup:

felixSchl commented 9 years ago

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

felixSchl commented 9 years ago

@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.

garyb commented 9 years ago

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

felixSchl commented 9 years ago

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?

garyb commented 9 years ago

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

felixSchl commented 9 years ago

Cheers :)