lean2/tests/lean/revapp.lean
Leonardo de Moura bf998d8661 feat(frontends/lean/parser): allow 'typeless' definitions, the type is inferred by the system
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-01 08:51:49 -07:00

29 lines
763 B
Text

Definition revapp {A : Type U} {B : A -> Type U} (a : A) (f : Pi (x : A), B x) : (B a) := f a.
Infixl 100 |> : revapp
Eval 10 |> (fun x, x + 1)
|> (fun x, x + 2)
|> (fun x, 2 * x)
|> (fun x, 3 - x)
|> (fun x, x + 2)
Definition revcomp {A B C: Type U} (f : A -> B) (g : B -> C) : A -> C :=
fun x, g (f x)
Infixl 100 #> : revcomp
Eval (fun x, x + 1) #>
(fun x, 2 * x * x) #>
(fun x, 10 + x)
Definition simple := (fun x, x + 1) #>
(fun x, 2 * x * x) #>
(fun x, 10 + x)
Check simple
Eval simple 10
Definition simple2 := (fun x : Int, x + 1) #>
(fun x, 2 * x * x) #>
(fun x, 10 + x)
Check simple2
Eval simple2 (-10)