on master help sign in
Move Pair/Sigma into Builtins namespace

Fixes #1775 (but there is still a related problem to address too, being #1776)

commit58dd2b50d73a2464cbaa4843406c5085875ffcc7 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateTue 9 Dec 2014, 15:14 (12 years ago) parentc943361
3 files changed+26−25
libs/prelude/Builtins.idr+20−19 src/Idris/AbsSyntaxTree.hs+4−4 test/quasiquote001/expected+2−2
libs/prelude/Builtins.idr+20−19
@@ -9,25 +9,26 @@
99 ||| The trivial constructor for `()`.
1010 MkUnit
1111
12−||| The non-dependent pair type, also known as conjunction.
13−||| @A the type of the left elements in the pair
14−||| @B the type of the left elements in the pair
15−%elim data Pair : (A : Type) -> (B : Type) -> Type where
16− ||| A pair of elements
17− ||| @a the left element of the pair
18− ||| @b the right element of the pair
19− MkPair : {A, B : Type} -> (a : A) -> (b : B) -> Pair A B
20−
21−||| Dependent pairs
22−|||
23−||| Dependent pairs represent existential quantification - they consist of a
24−||| witness for the existential claim and a proof that the property holds for
25−||| it. Another way to see dependent pairs is as just data - for instance, the
26−||| length of a vector paired with that vector.
27−|||
28−||| @ a the type of the witness @ P the type of the proof
29−data Sigma : (a : Type) -> (P : a -> Type) -> Type where
30− MkSigma : .{P : a -> Type} -> (x : a) -> (pf : P x) -> Sigma a P
12+namespace Builtins
13+ ||| The non-dependent pair type, also known as conjunction.
14+ ||| @A the type of the left elements in the pair
15+ ||| @B the type of the left elements in the pair
16+ %elim data Pair : (A : Type) -> (B : Type) -> Type where
17+ ||| A pair of elements
18+ ||| @a the left element of the pair
19+ ||| @b the right element of the pair
20+ MkPair : {A, B : Type} -> (a : A) -> (b : B) -> Pair A B
21+
22+ ||| Dependent pairs
23+ |||
24+ ||| Dependent pairs represent existential quantification - they consist of a
25+ ||| witness for the existential claim and a proof that the property holds for
26+ ||| it. Another way to see dependent pairs is as just data - for instance, the
27+ ||| length of a vector paired with that vector.
28+ |||
29+ ||| @ a the type of the witness @ P the type of the proof
30+ data Sigma : (a : Type) -> (P : a -> Type) -> Type where
31+ MkSigma : .{P : a -> Type} -> (x : a) -> (pf : P x) -> Sigma a P
3132
3233||| The empty type, also known as the trivially false proposition.
3334|||
src/Idris/AbsSyntaxTree.hs+4−4
@@ -1141,8 +1141,8 @@ falseDoc = fmap (const $ Msg "") . parseDocstring . T.pack $
11411141 "of type `Void` in scope."
11421142falseTy = sUN "Void"
11431143
1144−pairTy = sUN "Pair"
1145−pairCon = sUN "MkPair"
1144+pairTy = sNS (sUN "Pair") ["Builtins"]
1145+pairCon = sNS (sUN "MkPair") ["Builtins"]
11461146
11471147eqTy = sUN "="
11481148eqCon = sUN "Refl"
@@ -1183,8 +1183,8 @@ eqParamDoc = [(n "A", annotCode (const (Left $ Msg "")) . parseDocstring . T.pac
11831183eqOpts = []
11841184
11851185-- Defined in builtins.idr
1186−sigmaTy = sUN "Sigma"
1187−existsCon = sUN "MkSigma"
1186+sigmaTy = sNS (sUN "Sigma") ["Builtins"]
1187+existsCon = sNS (sUN "MkSigma") ["Builtins"]
11881188
11891189piBind :: [(Name, PTerm)] -> PTerm -> PTerm
11901190piBind = piBindp expl
test/quasiquote001/expected+2−2
@@ -1,5 +1,5 @@
11(App (App (App (P (DCon 1 3) (NS (UN ::) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (Bind (MN 0 "_t") (Pi (V 0)) (Bind (MN 2 "_t") (Pi (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 2)))))) (P (TCon 8 0) (UN Unit) (TType (UVar -1)))) (P (DCon 0 0) (UN MkUnit) (P (TCon 0 0) (UN Unit) Erased))) (App (App (App (P (DCon 1 3) (NS (UN ::) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (Bind (MN 0 "_t") (Pi (V 0)) (Bind (MN 2 "_t") (Pi (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 2)))))) (P (TCon 8 0) (UN Unit) (TType (UVar -1)))) (P (DCon 0 0) (UN MkUnit) (P (TCon 0 0) (UN Unit) Erased))) (App (P (DCon 0 1) (NS (UN Nil) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 0)))) (P (TCon 8 0) (UN Unit) (TType (UVar -1))))))
22--------------
3−(App (App (App (P (DCon 1 3) (NS (UN ::) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (Bind (MN 0 "_t") (Pi (V 0)) (Bind (MN 2 "_t") (Pi (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 2)))))) (TType (UVar 48))) (TType (UVar 50))) (App (App (App (P (DCon 1 3) (NS (UN ::) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (Bind (MN 0 "_t") (Pi (V 0)) (Bind (MN 2 "_t") (Pi (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 2)))))) (TType (UVar 52))) (App (App (App (App (P (DCon 0 4) (UN MkPair) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (UN Pair) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (P (TCon 8 0) (NS (UN Nat) ["Nat", "Prelude"]) (TType (UVar -1)))) (P (TCon 8 0) (NS (UN Nat) ["Nat", "Prelude"]) (TType (UVar -1))))) (App (P (DCon 0 1) (NS (UN Nil) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 0)))) (TType (UVar 54)))))
3+(App (App (App (P (DCon 1 3) (NS (UN ::) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (Bind (MN 0 "_t") (Pi (V 0)) (Bind (MN 2 "_t") (Pi (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 2)))))) (TType (UVar 48))) (TType (UVar 50))) (App (App (App (P (DCon 1 3) (NS (UN ::) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (Bind (MN 0 "_t") (Pi (V 0)) (Bind (MN 2 "_t") (Pi (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 2)))))) (TType (UVar 52))) (App (App (App (App (P (DCon 0 4) (NS (UN MkPair) ["Builtins"]) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (NS (UN Pair) ["Builtins"]) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (P (TCon 8 0) (NS (UN Nat) ["Nat", "Prelude"]) (TType (UVar -1)))) (P (TCon 8 0) (NS (UN Nat) ["Nat", "Prelude"]) (TType (UVar -1))))) (App (P (DCon 0 1) (NS (UN Nil) ["List", "Prelude"]) (Bind (UN a) (Pi (TType (UVar -1))) (App (P (TCon 0 0) (NS (UN List) ["List", "Prelude"]) Erased) (V 0)))) (TType (UVar 54)))))
44--------------
5−(App (App (App (App (P (DCon 0 4) (UN MkPair) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (UN Pair) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (App (App (App (App (P (DCon 0 4) (UN MkPair) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (UN Pair) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (TType (UVar 48))) (TType (UVar 48)))) (App (App (App (App (P (DCon 0 4) (UN MkPair) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (UN Pair) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (TType (UVar 48))) (TType (UVar 48))))
5+(App (App (App (App (P (DCon 0 4) (NS (UN MkPair) ["Builtins"]) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (NS (UN Pair) ["Builtins"]) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (App (App (App (App (P (DCon 0 4) (NS (UN MkPair) ["Builtins"]) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (NS (UN Pair) ["Builtins"]) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (TType (UVar 48))) (TType (UVar 48)))) (App (App (App (App (P (DCon 0 4) (NS (UN MkPair) ["Builtins"]) (Bind (UN A) (Pi (TType (UVar -1))) (Bind (UN B) (Pi (TType (UVar -1))) (Bind (UN a) (Pi (V 1)) (Bind (UN b) (Pi (V 1)) (App (App (P (TCon 0 0) (NS (UN Pair) ["Builtins"]) Erased) (V 3)) (V 2))))))) (TType (UVar 42))) (TType (UVar 44))) (TType (UVar 48))) (TType (UVar 48))))