From 22a655fd2477bf75e076b7159d1b64930cac7122 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Wed, 10 Jan 2024 12:45:41 +0100 Subject: [PATCH 1/3] write initial type signature notation proposal --- docs/design/type-notation.typ | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docs/design/type-notation.typ diff --git a/docs/design/type-notation.typ b/docs/design/type-notation.typ new file mode 100644 index 0000000..58977b9 --- /dev/null +++ b/docs/design/type-notation.typ @@ -0,0 +1,23 @@ +#import "../template.typ": conf +#show: doc => conf( + doc +) + += Type/signature notation + +Operator signature that takes two unnamed arbitrary numbers of the same type and returns another: +`Op [ T T ] -> T` + +Operator that takes a 32 bit signed integer and returns another: +`Op i32 -> i32` + +Operator that does the same with a generic arbitrary number type: +`Op T -> T` + +One dimensional list of 32 bit signed integers: +`[i32]` + +Due to inference, you'll also be able to use that in some mathematical operations with integers: + +`[i32] + i32` is a valid operation, for example (of course, you can't add types.) But that wouldn't add the second one to the list, but rather add the single i32 to all values in the left hand side list). That would also work with more dimensional arrays and dynamic streams like videos. + From e1dc5ce13284507821d89272d3eb19fe19faba11 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Thu, 11 Jan 2024 10:48:43 +0100 Subject: [PATCH 2/3] doc: change code from inline to blocks --- docs/design/type-notation.typ | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/design/type-notation.typ b/docs/design/type-notation.typ index 58977b9..18e7d95 100644 --- a/docs/design/type-notation.typ +++ b/docs/design/type-notation.typ @@ -1,21 +1,31 @@ #import "../template.typ": conf -#show: doc => conf( - doc -) +#show: conf = Type/signature notation Operator signature that takes two unnamed arbitrary numbers of the same type and returns another: -`Op [ T T ] -> T` + +```iowo +Op [ T T ] -> T +``` Operator that takes a 32 bit signed integer and returns another: -`Op i32 -> i32` + +```iowo +Op i32 -> i32 +``` Operator that does the same with a generic arbitrary number type: -`Op T -> T` + +```iowo +Op T -> T +``` One dimensional list of 32 bit signed integers: -`[i32]` + +```iowo +[i32] +``` Due to inference, you'll also be able to use that in some mathematical operations with integers: From b91e697449c77c54bac2ab123cf38863b8eedce1 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Thu, 11 Jan 2024 10:55:25 +0100 Subject: [PATCH 3/3] add example for multiple generics --- docs/design/type-notation.typ | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/design/type-notation.typ b/docs/design/type-notation.typ index 18e7d95..7858b50 100644 --- a/docs/design/type-notation.typ +++ b/docs/design/type-notation.typ @@ -9,6 +9,11 @@ Operator signature that takes two unnamed arbitrary numbers of the same type and Op [ T T ] -> T ``` +Operator signature that takes any color and any number type, and returns a color again: +```iowo +Op [ C M ] -> C +``` + Operator that takes a 32 bit signed integer and returns another: ```iowo