feat: add IO.eprint(ln) for printing to stderr
Most useful when stdout is being consumed by another program
This commit is contained in:
parent
0f6b9f5c94
commit
b40ef65b39
1 changed files with 10 additions and 4 deletions
|
|
@ -232,12 +232,18 @@ Prim.liftIO Prim.stdout
|
|||
def stderr : m FS.Handle :=
|
||||
Prim.liftIO Prim.stderr
|
||||
|
||||
private def putStr (s : String) : m Unit := do
|
||||
def print {α} [HasToString α] (s : α) : m Unit := do
|
||||
out ← stdout;
|
||||
out.putStr s
|
||||
out.putStr $ toString s
|
||||
|
||||
def println {α} [HasToString α] (s : α) : m Unit := print s *> print "\n"
|
||||
|
||||
def eprint {α} [HasToString α] (s : α) : m Unit := do
|
||||
out ← stderr;
|
||||
out.putStr $ toString s
|
||||
|
||||
def eprintln {α} [HasToString α] (s : α) : m Unit := eprint s *> eprint "\n"
|
||||
|
||||
def print {α} [HasToString α] (s : α) : m Unit := putStr ∘ toString $ s
|
||||
def println {α} [HasToString α] (s : α) : m Unit := print s *> putStr "\n"
|
||||
def getEnv : String → m (Option String) := Prim.liftIO ∘ Prim.getEnv
|
||||
def realPath : String → m String := Prim.liftIO ∘ Prim.realPath
|
||||
def isDir : String → m Bool := Prim.liftIO ∘ Prim.isDir
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue