Equations
- list.mmap' f (h :: t) = f h >> list.mmap' f t
- list.mmap' f list.nil = return ()
def
list.mfoldl
{m : Type u → Type v}
[monad m]
{s : Type u}
{α : Type w} :
(s → α → m s) → s → list α → m s
Equations
- list.mfoldl f s_1 (h :: r) = f s_1 h >>= λ (s' : s), list.mfoldl f s' r
- list.mfoldl f s_1 list.nil = return s_1
def
list.mfoldr
{m : Type u → Type v}
[monad m]
{s : Type u}
{α : Type w} :
(α → s → m s) → s → list α → m s
Equations
- list.mfoldr f s_1 (h :: r) = list.mfoldr f s_1 r >>= λ (s' : s), f h s'
- list.mfoldr f s_1 list.nil = return s_1
def
list.mfirst
{m : Type u → Type v}
[monad m]
[alternative m]
{α : Type w}
{β : Type u} :
(α → m β) → list α → m β
Equations
- list.mfirst f (a :: as) = (f a <|> list.mfirst f as)
- list.mfirst f list.nil = failure
Equations
Equations
Equations
Equations
def
monad.foldl
{m : Type u_1 → Type u_2}
[monad m]
{s : Type u_1}
{α : Type u_3} :
(s → α → m s) → s → list α → m s
Equations
Equations
Equations
- monad.sequence (h :: t) = h >>= λ (h' : α), monad.sequence t >>= λ (t' : list α), return (h' :: t')
- monad.sequence list.nil = return list.nil
Equations
- monad.sequence' (h :: t) = h >> monad.sequence' t
- monad.sequence' list.nil = return ()