andreypopp / andreypopp/rrun

stdlib

未關閉
#2 8 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
design
主要語言
OCaml
星號
19
分支
1
PR 合併指標
30 天內沒有已合併 PR

描述

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。