Skip to content

Commit 3367558

Browse files
Add ∏ as a synonym for Π
It's easier for Mac users to type (option-shift-P).
1 parent 073dfc7 commit 3367558

File tree

7 files changed

+40
-12
lines changed

7 files changed

+40
-12
lines changed

basics.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
(define-type Pie-Keyword
4040
(U 'U
4141
'Nat 'zero 'add1 'which-Nat 'iter-Nat 'rec-Nat 'ind-Nat
42-
'-> '→ 'Pi 'lambda
42+
'-> '→ 'Pi ' 'lambda
4343
'quote 'Atom
4444
'car 'cdr 'cons 'Sigma 'Pair
4545
'Trivial 'sole
@@ -377,7 +377,7 @@
377377
(not (or (eqv? x 'U) (eqv? x 'Nat) (eqv? x 'zero)
378378
(eqv? x 'add1) (eqv? x 'which-Nat) (eqv? x 'ind-Nat)
379379
(eqv? x 'rec-Nat) (eqv? x 'iter-Nat)
380-
(eqv? x '->) (eqv? x '→) (eqv? x ) (eqv? x 'Pi) (eqv? x ) (eqv? x 'lambda)
380+
(eqv? x '->) (eqv? x '→) (eqv? x ) (eqv? x 'Pi) (eqv? x ') (eqv? x 'λ) (eqv? x 'lambda)
381381
(eqv? x 'quote) (eqv? x 'Atom) (eqv? x ) (eqv? x 'Sigma) (eqv? x 'Pair)
382382
(eqv? x 'cons) (eqv? x 'car) (eqv? x 'cdr)
383383
(eqv? x 'Trivial) (eqv? x 'sole)

gui/pie-lexer.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
"car" "cdr" "cong" "trans" "symm" "replace")
397397
'keyword]
398398
[("U"
399-
"Π" "Pi" "->" ""
399+
"Π" "Pi" "" "->" ""
400400
"Σ" "Sigma" "Pair"
401401
"Either"
402402
"Atom"

main.rkt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
match norm
3333
(rename-out [kw:U U]
3434
[kw:Nat Nat] [kw:zero zero] [kw:add1 add1] [kw:which-Nat which-Nat] [kw:iter-Nat iter-Nat] [kw:rec-Nat rec-Nat] [kw:ind-Nat ind-Nat]
35-
[kw:-> ->] [kw:→ →] [kw:Π Π] [kw:λ λ] [kw:Pi Pi] [kw:lambda lambda]
35+
[kw:-> ->] [kw:→ →] [kw:Π Π] [kw:λ λ] [kw:Pi Pi] [kw:∏ ∏] [kw:lambda lambda]
3636
[kw:quote quote] [kw:Atom Atom]
3737
[kw:car car] [kw:cdr cdr] [kw:cons cons] [kw:Σ Σ] [kw:Sigma Sigma] [kw:Pair Pair]
3838
[kw:Trivial Trivial] [kw:sole sole]
@@ -276,13 +276,14 @@
276276
[grand-op-end (send txt get-forward-sexp (add1 grandparent-sexp-start))]
277277
[grand-op-start (send txt get-backward-sexp grand-op-end)]
278278
[grand-op (send txt get-text grand-op-start grand-op-end)])
279-
(if (member grand-op '("Pi" "Π" "Sigma" "Σ"))
279+
(if (member grand-op '("Pi" "Π" "" "Sigma" "Σ"))
280280
#t
281281
#f)))
282282
(define real-op
283283
(match op
284284
['lambda ]
285285
['Pi ]
286+
['∏ ]
286287
['Sigma ]
287288
['-> '→]
288289
[other other]))

parser.rkt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
#:datum-literals (U
238238
Nat zero add1
239239
which-Nat iter-Nat rec-Nat ind-Nat
240-
-> Pi Π the lambda λ Atom quote
240+
-> Pi Π the lambda λ Atom quote
241241
cons car cdr Sigma Σ Pair
242242
Trivial sole
243243
List :: nil ind-List rec-List
@@ -280,6 +280,8 @@
280280
(parse-pie #'b))]
281281
[(Pi ~! more ...)
282282
(parse-pie #'(Π more ...))]
283+
[(∏ ~! more ...)
284+
(parse-pie #'(Π more ...))]
283285
[(Π ~! (~describe "argument names and types"
284286
((x0:pie-id A0) (x:pie-id A) ...))
285287
(~describe "result type" B))
@@ -436,7 +438,7 @@
436438
#:datum-literals (U
437439
Nat zero add1
438440
which-Nat iter-Nat rec-Nat ind-Nat
439-
-> Pi Π the lambda λ Atom quote
441+
-> Pi Π the lambda λ Atom quote
440442
cons car cdr Sigma Σ Pair
441443
Trivial sole
442444
List :: nil ind-List rec-List
@@ -490,20 +492,28 @@
490492
b/bindings)))
491493
(car (syntax-e stx))))]
492494
[(Pi ~! ((x0:id A0) (x:id A) ...) B)
493-
(with-syntax ([pi/loc (syntax/loc (car (syntax-e stx)) kw:Pi)]
495+
(with-syntax ([sig/loc (syntax/loc (car (syntax-e stx)) kw:Pi)]
494496
[A0* #'(pie->binders A0)]
495497
[(A* ...) #'((pie->binders A) ...)]
496498
[B* #'(pie->binders B)])
497499
(add-disappeared (syntax/loc stx
498-
(void pi/loc (let* ([x0 A0*] [x A*] ...) B*)))
500+
(void sig/loc (let* ([x0 A0*] [x A*] ...) B*)))
499501
(car (syntax-e stx))))]
500502
[(Π ~! ((x0:id A0) (x:id A) ...) B)
501-
(with-syntax ([pi/loc (syntax/loc (car (syntax-e stx)) kw:Π)]
503+
(with-syntax ([sig/loc (syntax/loc (car (syntax-e stx)) kw:Π)]
502504
[A0* #'(pie->binders A0)]
503505
[(A* ...) #'((pie->binders A) ...)]
504506
[B* #'(pie->binders B)])
505507
(add-disappeared (syntax/loc stx
506-
(void pi/loc (let* ([x0 A0*] [x A*] ...) B*)))
508+
(void sig/loc (let* ([x0 A0*] [x A*] ...) B*)))
509+
(car (syntax-e stx))))]
510+
[(∏ ~! ((x0:id A0) (x:id A) ...) B)
511+
(with-syntax ([sig/loc (syntax/loc (car (syntax-e stx)) kw:∏)]
512+
[A0* #'(pie->binders A0)]
513+
[(A* ...) #'((pie->binders A) ...)]
514+
[B* #'(pie->binders B)])
515+
(add-disappeared (syntax/loc stx
516+
(void sig/loc (let* ([x0 A0*] [x A*] ...) B*)))
507517
(car (syntax-e stx))))]
508518
[(Sigma ~! ((x0:id A0) (x:id A) ...) B)
509519
(with-syntax ([sig/loc (syntax/loc (car (syntax-e stx)) kw:Sigma)]

pie-info.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(define-pie-keywords
2323
U
2424
Nat zero add1 which-Nat iter-Nat rec-Nat ind-Nat
25-
-> → Π λ Pi lambda
25+
-> → Π Pi ∏ λ lambda
2626
quote Atom
2727
car cdr cons Σ Sigma Pair
2828
Trivial sole

pie.scrbl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ The second projection of a pair. If @pie[p] is a @pie[(Σ ((_x _A)) _D)], then
233233
@def-type-constructor[(Pi ((x X1) (y X2) ...) B)]{
234234
@pie[Pi] is an alias for @pie[Π].
235235
}
236+
@def-type-constructor[(∏ ((x X1) (y X2) ...) B)]{
237+
@pie[∏] is an alias for @pie[Π] that is easier to type on some keyboards.
238+
}
236239
@def-type-constructor[(→ X1 X2 ... B)]{
237240
@pie[→], pronounced "arrow", is shorter way of writing @pie[(Π ((x X1) (x X2) ...) B)] when the identifiers @racket[x ...] are not used.}
238241
@def-type-constructor[(-> X1 X2 ... B)]{@pie[->] is an alias for @pie[→].}

tests.rkt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,3 +1637,17 @@
16371637
(λ (p)
16381638
((C to) p)))
16391639
b)))))))))))
1640+
1641+
;;; Check that ∏ works as a way of writing Π
1642+
(check-equal?
1643+
(rep init-ctx
1644+
(parse-pie #'((the (∏ ((A U) (B U))
1645+
(-> (Either A B)
1646+
(Either B A)))
1647+
(lambda (A B e)
1648+
(ind-Either e
1649+
(lambda (_) (Either B A))
1650+
(lambda (x) (right x))
1651+
(lambda (x) (left x)))))
1652+
Nat Trivial (left 2))))
1653+
(go '(the (Either Trivial Nat) (right (add1 (add1 zero))))))

0 commit comments

Comments
 (0)