faylang / fay

A proper subset of Haskell that compiles to JavaScript
https://github.com/faylang/fay/wiki
BSD 3-Clause "New" or "Revised" License
1.29k stars 86 forks source link

Fay as a Node.js server language #401

Closed gilbert closed 10 years ago

gilbert commented 10 years ago

Hello, I've look through Fay and it's very promising. Would you give me some insight on whether my goal with Fay is feasible or not?

My goal is to get the best of both Node.js asynchronous behaviour and Haskell's wonderful type system. What I'd like is to write pure business logic in Fay, then use plain JavaScript as a "dumb pipe". In other words, JavaScript will do the server listening, the I/O, the websockets, etc, while Fay will handle the business logic. The business logic will have several entry points (use cases, if you're familiar with them) that plain JavaScript will be able to use as black boxes.

Fay Architecture

Is this feasible? If so, what's the best approach to connecting the two parts?

bergmark commented 10 years ago

First of all, I don't really see a point in running Fay on the server side, why not just use Haskell and have it's wonderful typesystem AND it's even better asynchronous behavior? :-) Another advantage of having Haskell at the top level of your server is that you get type safe communication between server and client.

That said, here's a blog post about node.js and fay: http://kwangyulseo.com/2014/03/11/fay-node-js/ Depending on what you want to do you might need to modify the module output of Fay a bit so Fay modules can be imported from nodejs more easily, this is something that has been discussed before and I'd happily accept a pull request.

crabmusket commented 10 years ago

Hosting infrastructure? We can already use Heroku, more or less, but I'm not sure what the wider landscape looks like.

gilbert commented 10 years ago

The more I think about what you wrote, the more it makes sense. Fay makes more sense on the client side, where it can emit useful events, letting regular JavaScript to manipulate the DOM.

I will look more into Haskell and its WebSocket libraries. Thanks!