lean4-htt/library/init/list_classes.lean
Leonardo de Moura f00e6c0a96 feat(frontends/lean): anonymous instances
The instance name is synthesized automatically.
2016-09-23 13:34:34 -07:00

26 lines
708 B
Text

/-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
-/
prelude
import init.monad init.alternative
open list
universe variables u v
attribute [inline]
def list_fmap {A : Type u} {B : Type v} (f : A → B) (l : list A) : list B :=
map f l
attribute [inline]
def list_bind {A : Type u} {B : Type v} (a : list A) (b : A → list B) : list B :=
join (map b a)
attribute [inline]
def list_return {A : Type u} (a : A) : list A :=
[a]
instance : monad list :=
monad.mk @list_fmap @list_return @list_bind
instance : alternative list :=
alternative.mk @list_fmap @list_return (@fapp _ _) @nil @list.append