Skip to content

Commit 00bc488

Browse files
committed
Change to accept syms without parens and to declare multiple names
Syntax of names is changed such that in simple declaration and binding contexts the parentheses around a symbol can be omitted. For example, previously one would write: {(+), (-)} = Int (+): int -> int -> int Now one can also write: {+, -} = Int + : int -> int -> int Parentheses are still required when declaring symbol named functions: type (|) a b = ;; ... (+) x y = ;; ... Of course, the infix notation can still also be used: type a | n = ;; ... x + y = ;; ... Syntax of declarations is also changed such that multiple names can be declared with the same type. Previously one would write: (+): int -> int -> int (-): int -> int -> int Now one can also write: + - : int -> int -> int To make this possible, only implicit type parameters are allowed before the colon. Previously one could write: id a: a -> a Now one must write: id: (a : type) -> a -> a Implicit type parameters are still allowed before the colon: id 'a: a -> a As explicit type parameters preceding the colon are a relic from 1ML without type inference this should not cause major inconvenience. Syntax of paths (namelists) is also changed to allow symbols without parentheses.
1 parent 34c712c commit 00bc488

File tree

13 files changed

+198
-157
lines changed

13 files changed

+198
-157
lines changed

basis/index.1ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ List = import "./list"
66

77
type ORD = {
88
type t
9-
(<=) : t -> t ~> Bool.t
9+
<= : t -> t ~> Bool.t
1010
}
1111

1212
type SET = {

examples/fc.1ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ GADTs = {
3838
AssociatedTypes = {
3939
type EQ = {
4040
type t
41-
(==): t -> t -> bool
41+
== : t -> t -> bool
4242
}
4343

4444
type COLLECTS = {

examples/leibniz.1mls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type t a b
33
type a ~ b = t a b
44

55
id 'a: a ~ a ;; Reflexivity
6-
(<<) 'a 'b 'c: b ~ c -> a ~ b -> a ~ c ;; Transitivity
6+
<< 'a 'b 'c: b ~ c -> a ~ b -> a ~ c ;; Transitivity
77
invert 'a 'b: a ~ b -> b ~ a ;; Symmetry
88

99
to 'a 'b: a ~ b -> a -> b

examples/type-level.1ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ TypeLevel: {
2828

2929
not: t -> t
3030

31-
(&&&): t -> t -> t
32-
(|||): t -> t -> t
31+
&&& : t -> t -> t
32+
||| : t -> t -> t
3333

3434
equals: t -> t -> t
3535
}
@@ -56,15 +56,15 @@ TypeLevel: {
5656

5757
succ: t -> t
5858

59-
(+): t -> t -> t
60-
(*): t -> t -> t
59+
+ : t -> t -> t
60+
* : t -> t -> t
6161
}
6262

6363
List: {
6464
type t = type -> (type _ _ _) -> type
6565

6666
nil: t
67-
(::): type -> t -> t
67+
:: : type -> t -> t
6868

6969
map: (type _ _) -> t -> t
7070

lexer.mll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ let escape = ['n''t''\\''\'''\"']
253253
let character = [^'"''\\''\n'] | '\\'escape
254254

255255
let num = digit+
256-
let name = (letter | '_') (letter | digit | '_' | tick)*
256+
let word = (letter | '_') (letter | digit | '_' | tick)*
257257
let text = '"'character*'"'
258258
let char = '\''character '\''
259259

@@ -298,7 +298,7 @@ rule token = parse
298298
| "}" { RBRACE }
299299
| "," { COMMA }
300300
| ";" { SEMI }
301-
| name as s { NAME s }
301+
| word as s { WORD s }
302302
| symbol* as s { SYM s }
303303
| num as s { NUM (convert_num s) }
304304
| char as s { CHAR (convert_char s) }

paper.1ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ type EQ = {
6060
type MAP = {
6161
type key
6262
type map a
63-
empty (a : type) : map a
64-
add (a : type) : key -> a -> map a ~> map a
65-
lookup (a : type) : key -> map a ~> opt a
63+
empty : (a : type) -> map a
64+
add : (a : type) -> key -> a -> map a ~> map a
65+
lookup : (a : type) -> key -> map a ~> opt a
6666
}
6767

6868
Map (Key : EQ) :> MAP with (type key = Key.t) = {
@@ -101,8 +101,8 @@ entries (c : type) (C : COLL c) (xs : c) : list (C.key, C.val) =
101101
List.map (C.keys xs) (fun (k : C.key) => (k, caseopt (C.lookup xs k) bot id))
102102

103103
type MONAD (m : type -> type) = {
104-
return (a : type) : a ~> m a
105-
bind (a : type) (b : type) : m a -> (a ~> m b) ~> m b
104+
return : (a : type) -> a ~> m a
105+
bind : (a : type) -> (b : type) -> m a -> (a ~> m b) ~> m b
106106
}
107107
map (a : type) (b : type) (m : type -> type) (M : MONAD m) (f : a ~> b) (mx : m a) =
108108
M.bind a b mx (fun (x : a) => M.return b (f x)) ;; : m b

0 commit comments

Comments
 (0)