module Codata.IO.Core where

open import Level
open import Size

open import Agda.Builtin.Equality
open import Codata.Thunk
import IO.Primitive as Prim

_≤ˡ_ : Level  Level  Set
a ≤ˡ b = a  b  b

instance
  a≤a :  {a}  a ≤ˡ a
  a≤a = refl

{-# NO_UNIVERSE_CHECK #-}
data IO′ {a} ( : Level) (A : Set a) (i : Size) : Set (suc ) where
  lift   : {{eq : a ≤ˡ }}  Prim.IO {a} A  IO′  A i
  return : {{eq : a ≤ˡ }}  A  IO′  A i
  bind   :  {b} {B : Set b} 
           Thunk (IO′  B) i 
           (B  Thunk (IO′  A) i)  IO′  A i

pure :  {a } {A : Set a} {i}  {{a ≤ˡ }}  A  IO′  A i
pure = return

IO :  {a} ( : Level)  Set a  Set (suc )
IO  A = IO′  A