Debian Codegraph @

src/IO/Finite.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- IO only involving finite objects
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --guardedness #-}
8
9 module IO.Finite where
10
11 open import Data.Unit.Polymorphic.Base using (⊤)
12 open import Agda.Builtin.String using (String)
13 import Data.Unit.Base as Unit0 using (⊤)
14 open import IO.Base as Base using (IO; lift; lift′)
15 import IO.Primitive.Core as Prim using (IO; _>>=_; _>>_)
16 import IO.Primitive.Finite as Prim
17 using (getLine; readFile; writeFile; appendFile; putStr; putStrLn)
18 open import Level using (Level; Lift; 0ℓ; suc)
19
20 private
21 variable
22 a : Level
23
24 ------------------------------------------------------------------------
25 -- Simple lazy IO
26
27 -- Note that the functions below produce commands which, when
28 -- executed, may raise exceptions.
29
30 -- Note also that the semantics of these functions depends on the
31 -- version of the Haskell base library. If the version is 4.2.0.0 (or
32 -- later?), then the functions use the character encoding specified by
33 -- the locale. For older versions of the library (going back to at
34 -- least version 3) the functions use ISO-8859-1.
35
36 getLine : IO String
37 getLine = lift Prim.getLine
38
39 -- Reads a finite file. Raises an exception if the file path refers to
40 -- a non-physical file (like "/dev/zero").
41
42 readFile : String → IO String
43 readFile f = lift (Prim.readFile f)
44
45 writeFile : String → String → IO {a} ⊤
46 writeFile f s = lift′ (Prim.writeFile f s)
47
48 appendFile : String → String → IO {a} ⊤
49 appendFile f s = lift′ (Prim.appendFile f s)
50
51 putStr : String → IO {a} ⊤
52 putStr s = lift′ (Prim.putStr s)
53
54 putStrLn : String → IO {a} ⊤
55 putStrLn s = lift′ (Prim.putStrLn s)