lean4-htt/library/init/category/functor.lean
Sebastian Ullrich a4db338053 fix(init/category/functor): make $> actually usable
The abstraction in the previous definition prevented successful elaboration
2018-02-02 08:58:52 -08:00

30 lines
1.2 KiB
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) Luke Nelson and Jared Roesch. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Luke Nelson, Jared Roesch, Sebastian Ullrich, Leonardo de Moura
-/
prelude
import init.core init.function init.meta.name
open function
universes u v
section
set_option auto_param.check_exists false
class has_map (f : Type u → Type v) : Type (max (u+1) v) :=
(map : Π {α β : Type u}, (α → β) → f α → f β)
(map_const : Π {α β : Type u}, α → f β → f α := λ α β, map ∘ const β)
infixr ` <$> `:100 := has_map.map
infixr ` <$ `:100 := has_map.map_const
@[reducible] def has_map.map_const_rev {f : Type u → Type v} [has_map f] {α β : Type u} : f β → α → f α :=
λ a b, b <$ a
infixr ` $> `:100 := has_map.map_const_rev
class functor (f : Type u → Type v) extends has_map f : Type (max (u+1) v) :=
(map_const_eq : ∀ {α β : Type u}, @map_const α β = map ∘ const β . control_laws_tac)
-- `functor` is indeed a categorical functor
(id_map : Π {α : Type u} (x : f α), id <$> x = x)
(map_comp : Π {α β γ : Type u} (g : α → β) (h : β → γ) (x : f α), (h ∘ g) <$> x = h <$> g <$> x)
end