Skip to content

Commit 04ad50e

Browse files
committed
Syntax fixes
1 parent d7aab14 commit 04ad50e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/docs/internals/syntax.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ FunType ::= FunArgTypes ‘=>’ Type
146146
FunArgTypes ::= InfixType
147147
| ‘(’ [ ‘[given]’ FunArgType {‘,’ FunArgType } ] ‘)’
148148
| ‘(’ ‘[given]’ TypedFunParam {‘,’ TypedFunParam } ‘)’
149+
GivenArgs ::= InfixType
150+
| ‘(’ [ FunArgType {‘,’ FunArgType } ] ‘)’
151+
| ‘(’ ‘val’ TypedFunParam {‘,’ ‘val’ TypedFunParam } ‘)’
149152
TypedFunParam ::= id ‘:’ Type
150153
MatchType ::= InfixType `match` ‘{’ TypeCaseClauses ‘}’
151154
InfixType ::= RefinedType {id [nl] RefinedType} InfixOp(t1, op, t2)

docs/docs/reference/contextual-witnesses/witnesses.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ trait Ord[T] {
1313
def (x: T) > (y: T) = compare(x, y) > 0
1414
}
1515

16-
witness intOrd of Ord[Int] with
16+
witness intOrd of Ord[Int] {
1717
def compare(x: Int, y: Int) =
1818
if (x < y) -1 else if (x > y) +1 else 0
19+
}
1920

20-
witness listOrd[T](given ord: Ord[T]) of Ord[List[T]] with
21+
witness listOrd[T](given ord: Ord[T]) of Ord[List[T]] {
2122

2223
def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match
2324
case (Nil, Nil) => 0
@@ -26,6 +27,7 @@ witness listOrd[T](given ord: Ord[T]) of Ord[List[T]] with
2627
case (x :: xs1, y :: ys1) =>
2728
val fst = ord.compare(x, y)
2829
if (fst != 0) fst else compare(xs1, ys1)
30+
}
2931
```
3032
This code defines a trait `Ord` with two witnesses. `intOrd` defines
3133
a witness of the type `Ord[Int]` whereas `listOrd[T]` defines witnesses

0 commit comments

Comments
 (0)