lean4-htt/library/init/control/monadfail.lean
2019-07-02 17:35:15 -07:00

18 lines
594 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import init.control.lift init.data.string.basic
universes u v
class MonadFail (m : Type u → Type v) :=
(fail {} : ∀ {a}, String → m a)
def matchFailed {α : Type u} {m : Type u → Type v} [MonadFail m] : m α :=
MonadFail.fail "match failed"
instance monadFailLift (m n : Type u → Type v) [HasMonadLift m n] [MonadFail m] [Monad n] : MonadFail n :=
{ fail := fun α s => monadLift (MonadFail.fail s : m α) }