~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to test-suite/success/LetPat.v

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(* Simple let-patterns *)
 
2
Variable A B : Type.
 
3
 
 
4
Definition l1 (t : A * B * B) : A := let '(x, y, z) := t in x.
 
5
Print l1.
 
6
Definition l2 (t : (A * B) * B) : A := let '((x, y), z) := t in x.
 
7
Definition l3 (t : A * (B * B)) : A := let '(x, (y, z)) := t in x.
 
8
Print l3.
 
9
 
 
10
Record someT (A : Type) := mkT { a : nat; b: A }.
 
11
 
 
12
Definition l4 A (t : someT A) : nat := let 'mkT x y := t in x.
 
13
Print l4.
 
14
Print sigT.
 
15
 
 
16
Definition l5 A (B : A -> Type) (t : sigT B) : B (projT1 t) := 
 
17
  let 'existT x y := t return B (projT1 t) in y.
 
18
 
 
19
Definition l6 A (B : A -> Type) (t : sigT B) : B (projT1 t) := 
 
20
  let 'existT x y as t' := t return B (projT1 t') in y.
 
21
 
 
22
Definition l7 A (B : A -> Type) (t : sigT B) : B (projT1 t) := 
 
23
  let 'existT x y as t' in sigT _ := t return B (projT1 t') in y.
 
24
 
 
25
Definition l8 A (B : A -> Type) (t : sigT B) : B (projT1 t) := 
 
26
  match t with
 
27
    existT x y => y
 
28
  end.
 
29
 
 
30
(** An example from algebra, using let' and inference of return clauses
 
31
   to deconstruct contexts. *)
 
32
 
 
33
Record a_category (A : Type) (hom : A -> A -> Type) := {  }.
 
34
 
 
35
Definition category := { A : Type & { hom : A -> A -> Type & a_category A hom } }.
 
36
 
 
37
Record a_functor (A : Type) (hom : A -> A -> Type) (C : a_category A hom) := {  }.
 
38
 
 
39
Notation " x :& y " := (@existT _ _ x y) (right associativity, at level 55) : core_scope.
 
40
 
 
41
Definition functor (c d : category) :=
 
42
  let ' A :& homA :& CA := c in
 
43
  let ' B :& homB :& CB := d in
 
44
    A -> B.
 
45
 
 
46
Definition identity_functor (c : category) : functor c c :=
 
47
  let 'A :& homA :& CA := c in
 
48
    fun x => x.
 
49
 
 
50
Definition functor_composition (a b c : category) : functor a b -> functor b c -> functor a c := 
 
51
  let 'A :& homA :& CA := a in
 
52
  let 'B :& homB :& CB := b in
 
53
  let 'C :& homB :& CB := c in
 
54
    fun f g => 
 
55
      fun x => g (f x).