lean4-htt/src/Lean/Data/LOption.lean
Markus Himmel 9402c307fe
chore: reorganize Init imports around strings (#10289)
This PR reorganizes the import hierarchy so that
`Init.Data.String.Basic` can import `Init.Data.UInt.Bitwise` and
`Init.Data.Array.Lemmas`.
2025-09-07 17:09:14 +00:00

41 lines
952 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) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
module
prelude
public import Init.Data.ToString.Basic
public import Init.Data.String.Basic
public section
universe u
namespace Lean
inductive LOption (α : Type u) where
| none : LOption α
| some : α → LOption α
| undef : LOption α
deriving Inhabited, BEq
instance [ToString α] : ToString (LOption α) where
toString
| .none => "none"
| .undef => "undef"
| .some a => "(some " ++ toString a ++ ")"
def LOption.toOption : LOption α → Option α
| .some a => .some a
| _ => .none
end Lean
def Option.toLOption {α : Type u} : Option α → Lean.LOption α
| none => .none
| some a => .some a
@[inline] def toLOptionM {α} {m : Type → Type} [Monad m] (x : m (Option α)) : m (Lean.LOption α) := do
let b ← x
return b.toLOption