Debian Codegraph @

src/IO/Primitive/Core.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Primitive IO: simple bindings to Haskell types and functions
5 ------------------------------------------------------------------------
6
7 -- NOTE: the contents of this module should be accessed via `IO`.
8
9 {-# OPTIONS --cubical-compatible #-}
10
11 module IO.Primitive.Core where
12
13 open import Level using (Level)
14 private
15 variable
16 a : Level
17 A B : Set a
18
19 ------------------------------------------------------------------------
20 -- The IO monad
21
22 open import Agda.Builtin.IO public
23 using (IO)
24
25 infixl 1 _>>=_
26
27 postulate
28 pure : A → IO A
29 _>>=_ : IO A → (A → IO B) → IO B
30
31 {-# COMPILE GHC pure = \_ _ -> return #-}
32 {-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-}
33 {-# COMPILE UHC pure = \_ _ x -> UHC.Agda.Builtins.primReturn x #-}
34 {-# COMPILE UHC _>>=_ = \_ _ _ _ x y -> UHC.Agda.Builtins.primBind x y #-}
35
36 -- Haskell-style alternative syntax
37 return : A → IO A
38 return = pure
39
40 _>>_ : IO A → IO B → IO B
41 a >> b = a >>= λ _ → b