Debian Codegraph @

src/Reflection/TCM/Syntax.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Monad syntax for the TC monad
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Reflection.TCM.Syntax where
10
11 open import Agda.Builtin.Reflection
12 open import Level using (Level)
13
14 private
15 variable
16 a b : Level
17 A : Set a
18 B : Set b
19
20 ------------------------------------------------------------------------
21 -- Monad syntax
22
23 infixl 3 _<|>_
24 _<|>_ : TC A → TC A → TC A
25 _<|>_ = catchTC
26 {-# INLINE _<|>_ #-}
27
28 infixl 1 _>>=_ _>>_ _<&>_
29 _>>=_ : TC A → (A → TC B) → TC B
30 _>>=_ = bindTC
31 {-# INLINE _>>=_ #-}
32
33 _>>_ : TC A → TC B → TC B
34 xs >> ys = bindTC xs (λ _ → ys)
35 {-# INLINE _>>_ #-}
36
37 infixl 4 _<$>_ _<*>_ _<$_
38 _<*>_ : TC (A → B) → TC A → TC B
39 fs <*> xs = bindTC fs (λ f → bindTC xs (λ x → returnTC (f x)))
40 {-# INLINE _<*>_ #-}
41
42 _<$>_ : (A → B) → TC A → TC B
43 f <$> xs = bindTC xs (λ x → returnTC (f x))
44 {-# INLINE _<$>_ #-}
45
46 _<$_ : A → TC B → TC A
47 x <$ xs = bindTC xs (λ _ → returnTC x)
48 {-# INLINE _<$_ #-}
49
50 _<&>_ : TC A → (A → B) → TC B
51 xs <&> f = bindTC xs (λ x → returnTC (f x))
52 {-# INLINE _<&>_ #-}