Write CLI scripts in Elm (IO Monad)

Files API

Yupp

I mean, most errors are not avoidable at the API level: write errors, permission errors, full filesystem, etc etc etc, can and need to be managed via Result/IO err, as you already do.

Writing to a closed fd feels like one of those problems that are be fixable with a Strict Enough API but:

  1. not sure it actually exists in the Elm typesystem
  2. not sure, if it exists, if it is nice enough to be worth using over a trivial withFile : (FD -> IO e a) -> IO e a
  3. not sure, if it exists, if it’s flexible enough for all usecases

Something something records keeping tracks of open files via type level shenanigans, elm-css-ish style.

I think allowing either a value or a Promise should be flexible enough yet clean and avoid the issue.

1 Like