andreypopp / andreypopp/rrun

stdlib

Offen
#2 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
design
Vorherrschende Sprache
OCaml
Sterne
19
Forks
1
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

We want to ship a set of libraries with rrun, I'm now thinking more about
libraries which implement portable APIs to operating system facilities rather
than data structures (though we should explore this topic too).

### How to expose stdlib to user code

I think we should use `[%import "..."]` syntax which is used already for user
code. Currently such syntax only allows relative paths and https URLs, that
means we can use plain (non-path) strings for stdlib:

```
module Path = [%import "path"]
module Cmd = [%import "cmd"]
```

### CamelCase or snake\_case

Definitely CamelCase.

### Concurrency primitive

All I/O should be concurrent, like in Node.

Decide what we should use:

- `lwt`
- `async`
- `repromise`

I'd like to explore `repromise` but we might need to sync up with aantron on
that - is it ready for experimentation at least?

### Proposed modules to include in stdlib

- `Promise` - concurrency primitive exposed (`repromise` or whatever we've chosen).

- `Promise.return`

- `Promise.join`

- `Promise.sleep`

- `Promise.List.map`

- `Promise.List.iter`

- `Path` - working with filesystem paths, I like how `fpath` is designed, we
might just take it and use.

- `Cmd` - compose command invocations and execute them, I like how `bos`
library has `Bos.Cmd` and `Bos.OS.Cmd`, few notes regarding them though:

- While `bos` has two separate modules for constructing commands and running
commands, I think we should go with a single `Cmd` module.

- `Bos.Cmd` allows to construct and empty command invocation which is then
fails if you try executing it. I think we should disallow that and I already
have such `Cmd` implementation in `esy-lib/Cmd`, we could take it.

- I like how `bos` allows you to compose command invocations with combinators
(modified bos API in the example below):

```
let catString = (s) =>
Cmd.(inString(s) |> run v("cat") |> outString);
```

- `Fs` - access to file system:

- `Fs.readFile`
- `Fs.writeFile`
- `Fs.listDir`
- `Fs.createDir`
- ...

- `Json`

- `Http` - HTTP protocol

- `Http.Fetch` - HTTP client

- `Http.Serve` - HTTP server

- `CommandLine` - parsing command line arguments/options. Take a look at
`cmdliner` maybe? Though it's not as trivial to use, might take something more
simple.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.