Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
[#556] Use round parentheses for type constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhue committed Mar 21, 2021
1 parent a100c78 commit 7a41e11
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export const buildGenericType = (
singleParameter = false,
) =>
seq(
'<',
'(',
singleParameter ? field(name, rule) : commaSep1(field(name, rule)),
'>',
')',
)

export const buildTypeConstraint = <RuleName extends string>(
Expand Down
4 changes: 0 additions & 4 deletions dtn/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ export type UnnamedType =
| ":"
| "::"
| ";"
| "<"
| "<:"
| ">"
| "?"
| "@"
| "["
Expand Down Expand Up @@ -277,9 +275,7 @@ export type SyntaxNode =
| UnnamedNode<":">
| UnnamedNode<"::">
| UnnamedNode<";">
| UnnamedNode<"<">
| UnnamedNode<"<:">
| UnnamedNode<">">
| UnnamedNode<"?">
| UnnamedNode<"@">
| UnnamedNode<"[">
Expand Down
10 changes: 5 additions & 5 deletions tony/corpus/terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ else 1
class
==================

class Type<T>
class Type(T)
a :: T -> Number
b :: T -> Number
class Ord<T <: (Num; Eq; Ord)>
class T <: (Num; Eq; Ord) => Ord(T)
compare :: T -> T -> Number

---
Expand Down Expand Up @@ -753,7 +753,7 @@ class Ord<T <: (Num; Eq; Ord)>
instance
==================

instance Ord<Number>
instance Ord(Number)
compare := 1

---
Expand Down Expand Up @@ -1039,8 +1039,8 @@ type alias
type Type := Type
type Type := :tag Type
type Type := :tag Type | :tag ()
type Type<T, U <: Num> := T -> U
type GreaterThan<T>(x :: T) := [y :: T | y > x]
type U <: Num => Type(T, U) := T -> U
type T <: Ord => GreaterThan(T, x :: T) := [y :: T | y > x]

---

Expand Down
1 change: 1 addition & 0 deletions tony/grammar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export = grammar({
[$.tagged_value, $.tagged_pattern, $.tagged_type],
[$.tagged_value, $.tagged_type],
[$.tagged_pattern, $.tagged_type],
[$.type_variable_declaration, $.parametric_type],
],

precedences: () => [],
Expand Down
6 changes: 1 addition & 5 deletions tony/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,9 @@ export type UnnamedType =
| "::"
| ":="
| ";"
| "<"
| "<:"
| "="
| "=>"
| ">"
| "?"
| "@"
| "["
Expand Down Expand Up @@ -398,11 +396,9 @@ export type SyntaxNode =
| UnnamedNode<"::">
| UnnamedNode<":=">
| UnnamedNode<";">
| UnnamedNode<"<">
| UnnamedNode<"<:">
| UnnamedNode<"=">
| UnnamedNode<"=>">
| UnnamedNode<">">
| UnnamedNode<"?">
| UnnamedNode<"@">
| UnnamedNode<"[">
Expand Down Expand Up @@ -430,8 +426,8 @@ export type SyntaxNode =
| UnnamedNode<SyntaxType.Return>
| UnnamedNode<"then">
| UnnamedNode<"true">
| TypeNode
| UnnamedNode<SyntaxType.Type>
| TypeNode
| TypeVariableDeclarationNameNode
| UnnamedNode<SyntaxType.Typeof>
| UnnamedNode<SyntaxType.When>
Expand Down

0 comments on commit 7a41e11

Please sign in to comment.