{-# OPTIONS --cubical-compatible --guardedness #-}
module IO where
open import Codata.Musical.Notation
open import Codata.Musical.Costring
open import Data.Unit.Polymorphic.Base
open import Data.String.Base
import Data.Unit.Base as Unit0
open import Function.Base using (_∘_)
import IO.Primitive as Prim
open import Level
private
variable
a b : Level
A : Set a
B : Set b
open import IO.Base public
module Colist where
open import Codata.Musical.Colist.Base
sequence : Colist (IO A) → IO (Colist A)
sequence [] = return []
sequence (c ∷ cs) = bind (♯ c) λ x → ♯
bind (♯ sequence (♭ cs)) λ xs → ♯
return (x ∷ ♯ xs)
sequence′ : Colist (IO A) → IO ⊤
sequence′ [] = return _
sequence′ (c ∷ cs) = seq (♯ c) (♯ sequence′ (♭ cs))
mapM : (A → IO B) → Colist A → IO (Colist B)
mapM f = sequence ∘ map f
mapM′ : (A → IO B) → Colist A → IO ⊤
mapM′ f = sequence′ ∘ map f
module List where
open import Data.List.Base
sequence : List (IO A) → IO (List A)
sequence [] = ⦇ [] ⦈
sequence (c ∷ cs) = ⦇ c ∷ sequence cs ⦈
sequence′ : List (IO A) → IO ⊤
sequence′ [] = return _
sequence′ (c ∷ cs) = c >> sequence′ cs
mapM : (A → IO B) → List A → IO (List B)
mapM f = sequence ∘ map f
mapM′ : (A → IO B) → List A → IO ⊤
mapM′ f = sequence′ ∘ map f
open import IO.Finite public
renaming (readFile to readFiniteFile)
open import IO.Infinite public
renaming ( writeFile to writeFile∞
; appendFile to appendFile∞
; putStr to putStr∞
; putStrLn to putStrLn∞
)