Commit graph

52 commits

Author SHA1 Message Date
Sebastian Ullrich
95901a0346 fix: make Stream.ofBuffer thread-safe 2020-08-28 10:04:32 -07:00
Sebastian Ullrich
110ae4b571 feat: replace OS-specific stream redirection with pure-Lean Stream redirection
This avoids the temporary files workaround on macOS and Windows, and makes sure
we can process a `#eval` command and write messages to stdout at the same time.
2020-08-28 10:04:32 -07:00
Sebastian Ullrich
efa119bc94 feat: make std streams Streams 2020-08-28 10:04:32 -07:00
Sebastian Ullrich
1b0ffbb74d feat: make std IO streams settable
Co-authored-by: Simon Hudon <simon.hudon@gmail.com>
2020-08-28 10:04:32 -07:00
Leonardo de Moura
321719b300 feat: add MonadFinally 2020-08-25 17:58:35 -07:00
Leonardo de Moura
1103806ff4 refactor: HasMonadLift ==> MonadLift 2020-08-25 13:54:41 -07:00
Leonardo de Moura
77b9445544 feat: real ST monad
@Kha: the new `ST` (and `EST`) are escapable like the Haskell ST monad.
It makes `StateRefT` much more useful because we can now run it from pure
code.
2020-08-23 12:15:32 -07:00
Leonardo de Moura
05a0e7f6d0 refactor: build all main monads on top of ECoreM 2020-08-20 18:36:04 -07:00
Leonardo de Moura
fad6235abb feat: give a name to EIO Empty
@Kha I am calling it `ST` for lack of a better name. It makes some
sense since only the `IO.Ref` operations are in `EIO Empty` :)
That being said, it may confuse Haskell users.

BTW, I had to give the name to avoid a nontermination in the TC
procedure when using
```lean
instance EIOEmpty.monadLift {ε} : HasMonadLift (EIO Empty) (EIO ε) :=
{ monadLift := fun α => fromEmptyEIO }
```
2020-08-20 15:47:27 -07:00
Leonardo de Moura
eebc611391 chore: remove unnecessary workaround 2020-08-20 13:15:11 -07:00
Leonardo de Moura
968457ac1c feat: make sure StateRefT can be used with any base EIO Exception 2020-08-20 13:11:12 -07:00
Leonardo de Moura
d36ccb166c feat: use EIO Empty instead of IO at IO.Ref primitives 2020-08-20 12:54:15 -07:00
Leonardo de Moura
c55376a1ba chore: more conventional MonadIO 2020-08-20 11:13:10 -07:00
Leonardo de Moura
4e736bcca0 feat: use trick to inform compiler that a builtin doesn't throw exceptions 2020-08-20 11:05:11 -07:00
Leonardo de Moura
c0dbf60830 feat: remove IO.ref.reset
`reset` was used to implement a "buggy" `IO.ref.modify`.
```lean
@[inline] def Ref.modify {α : Type} (r : Ref α) (f : α → α) : m Unit := do
v ← r.get;
r.reset;
r.set (f v)
```
`IO.Ref.reset` will store a nullptr in `r`.
Now, suppose another thread tries to read this reference,
it will get an `IO.error`.
It is not a crash, but it is really weird behavior.
2020-08-20 10:07:15 -07:00
Leonardo de Moura
b5ed59ef61 chore: missing [inline] 2020-08-19 17:10:52 -07:00
Leonardo de Moura
9158ba60ea feat: add IO.toEIO 2020-08-19 09:43:26 -07:00
Leonardo de Moura
390aef535e chore: remove workaround 2020-08-18 17:22:51 -07:00
Leonardo de Moura
e70ff5b773 refactor: simplify CoreM using StateRefT 2020-08-18 16:02:29 -07:00
Leonardo de Moura
b8044fdf97 chore: remove MonadExceptOf from MonadIO
@Kha we currently do not need this feature. We may add it back when needed.
2020-08-18 15:40:16 -07:00
Leonardo de Moura
aa2f834c0f feat: add mkMonadIO and modifyGet 2020-08-18 13:25:15 -07:00
Leonardo de Moura
6c234daad7 chore: MonadExceptCore => MonadExceptOf 2020-08-13 09:28:23 -07:00
Wojciech Nawrocki
55655869b7 feat: default to binary file mode on Windows 2020-08-13 09:21:35 -07:00
Leonardo de Moura
d7add53229 feat: add MonadExceptCore 2020-08-13 09:19:26 -07:00
Sebastian Ullrich
b40ef65b39 feat: add IO.eprint(ln) for printing to stderr
Most useful when stdout is being consumed by another program
2020-07-06 09:22:47 -07:00
Sebastian Ullrich
6404af6983 feat: IO.Prim.withIsolatedStreams 2020-06-16 10:41:42 -07:00
Sebastian Ullrich
f4c28fbe5f chore: remove unnecessary getByte/putByte IO primitives 2020-06-16 12:06:53 +02:00
Simon Hudon
a64e78b90b feat: add std streams
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2020-06-16 12:06:53 +02:00
Sebastian Ullrich
be79820a47 feat: add IO.currentDir 2020-05-14 14:38:52 +02:00
Leonardo de Moura
098b0edbcb chore: remove dead code 2020-03-23 15:56:29 -07:00
Leonardo de Moura
2cc0f25bf5 feat: getLine at EOF should return empty string
This is the same approach used in Rust, and it simplifies the code.
2020-03-23 15:44:47 -07:00
Leonardo de Moura
dc80b76106 feat: add IO.FS.lines 2020-03-23 14:53:27 -07:00
Leonardo de Moura
94f016a3e8 fix: readLine and test 2020-03-23 14:06:17 -07:00
Sebastian Ullrich
4cff135ec3 feat: #eval: auto-hide () output for m Unit chained instances 2020-03-19 17:18:15 -07:00
Sebastian Ullrich
2509b3913a Revert "feat: add std streams"
This reverts commit 7575a32035.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
0be2424910 Revert "feat: override standard streams"
This reverts commit bd87ea5d5e.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
b760692a26 Revert "fix: thread local storage of std streams"
This reverts commit 961861ceab.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
a4858bf9f9 Revert "feat: MonadIO now extends MonadExcept IO.Error"
This reverts commit c0a7495495.
2020-01-25 16:32:06 +01:00
Simon Hudon
c0a7495495 feat: MonadIO now extends MonadExcept IO.Error 2020-01-19 17:23:37 -08:00
Simon Hudon
961861ceab fix: thread local storage of std streams 2020-01-19 17:23:24 -08:00
Simon Hudon
bd87ea5d5e feat: override standard streams 2020-01-19 17:23:12 -08:00
Simon Hudon
7575a32035 feat: add std streams
This reverts commit 021ce21d5f70c2efcc58a0588ed6dc4999be6a33.
2020-01-19 17:22:58 -08:00
Simon Hudon
6d8927da10 fix: little details 2020-01-12 08:02:48 -08:00
Simon Hudon
92c8773137 feat: file IO using handles 2020-01-12 08:02:48 -08:00
Leonardo de Moura
01c5b0710c feat: pointer equality for IO.ref 2020-01-08 21:09:17 -08:00
Leonardo de Moura
bc7455e04e refactor: CommandElabM and FrontendM in IO 2020-01-03 18:15:45 -08:00
Leonardo de Moura
3264210d88 chore: helper functions 2020-01-03 12:24:14 -08:00
Leonardo de Moura
c3005671f5 chore: avoid ^do ... 2019-12-11 06:19:12 -08:00
Leonardo de Moura
87a617cb8c chore: Fs ==> FS 2019-12-09 15:25:55 -08:00
Leonardo de Moura
13fb335841 chore: monadIO ==> MonadIO 2019-12-09 15:25:05 -08:00