Write CLI scripts in Elm (IO Monad)

Files API

I think the ideas you are writing about are interesting, thank you.

I want to be pragmatic in the design of the API. The “gut feelings” I have been basing my decisions on are something like this:

  • 90% of the use cases for this package would be satisfied with just reading / writing whole files at once.
  • Writing to closed file descriptors are just one of all the problems you can have and need to watch out for. I am afraid that solving this without something like linear types would make API feel very complex. But of course I am open to suggestions and I will try to think in the lines the ideas you are describing.

Call JS

I had that in the beginning but then I wanted to do async stuff, like

sleep: function(delay) {
    setTimeout(this.send, delay);
}

so I went with the more flexible approach of using callbacks. My thinking was that increased flexibility outweighs the increased risk. I’m open to other opinions or suggestions here though, maybe it is better to revert to returning values.
Is it maybe a better idea to have the functions return either a value or a Promise to allow both styles?

2 Likes