Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Init/Control/Except.lean
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ then the result is the result of the second computation.

This is the implementation of the `>>=` operator for `Except ε`.
-/
@[always_inline, inline]
protected def bind (ma : Except ε α) (f : α → Except ε β) : Except ε β :=
@[always_inline]
protected abbrev bind (ma : Except ε α) (f : α → Except ε β) : Except ε β :=
match ma with
| Except.error err => Except.error err
| Except.ok v => f v

set_option allowUnsafeReducibility true in
attribute [semireducible] Except.bind

/-- Returns `true` if the value is `Except.ok`, `false` otherwise. -/
@[always_inline, inline]
protected def toBool : Except ε α → Bool
Expand Down
7 changes: 5 additions & 2 deletions src/Init/Control/Option.lean
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ protected def mk (x : m (Option α)) : OptionT m α :=
/--
Sequences two potentially-failing actions. The second action is run only if the first succeeds.
-/
@[always_inline, inline, expose]
protected def bind (x : OptionT m α) (f : α → OptionT m β) : OptionT m β := OptionT.mk do
@[always_inline]
protected abbrev bind (x : OptionT m α) (f : α → OptionT m β) : OptionT m β := OptionT.mk do
match (← x) with
| some a => f a
| none => pure none

set_option allowUnsafeReducibility true in
attribute [semireducible] OptionT.bind

/--
Succeeds with the provided value.
-/
Expand Down
Loading