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

Commit

Permalink
[#565] Change type hint operator from as to ::
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhue committed Mar 25, 2021
1 parent ac889de commit d3d73fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export enum Prec {
SubtractionType = -1,
UnionType = 0,
Assignment = 1,
TypeHint = 1,
TypeHint = 0,
CurriedType = 1,
NamedInfixApplication = 1,
SectionIdentifier = 1,
Expand Down
2 changes: 1 addition & 1 deletion common/terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export const type_hint = <RuleName extends string>(
) =>
prec.left(
Prec.TypeHint,
seq(field('value', $._term), 'as', field('type', $._type)),
seq(field('value', $._term), '::', field('type', $._type)),
)

export const hole = <RuleName extends string>($: GrammarSymbols<RuleName>) =>
Expand Down
11 changes: 9 additions & 2 deletions tony/corpus/terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1084,15 +1084,22 @@ type GreaterThan<T>(x :: T) = [y :: T | y > x]
type hint
==================

'string' as String
'string' :: String
x :: Promise<Number>

---

(program
term: (type_hint
value: (string)
type: (parametric_type
name: (type))))
name: (type)))
term: (type_hint
value: (identifier)
type: (parametric_type
name: (type)
argument: (parametric_type
name: (type)))))

==================
hole
Expand Down

0 comments on commit d3d73fc

Please sign in to comment.