Debian Codegraph @

src/IO/Infinite.agda

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