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}
(f : α → 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 ()