From e64d72120de2af63a068687e3623ed509cdc6cab Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Sun, 23 Apr 2017 16:22:42 +0200 Subject: [PATCH 1/9] Update Syntax.md --- language/Syntax.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/language/Syntax.md b/language/Syntax.md index 5a64542f..9aa3a7ea 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -402,7 +402,7 @@ conditional = if 2 > 1 then "ok" else "oops" ## Let and where bindings -The `let` keyword a collection of local declarations, which may be mutually recursive, and which may include type declarations: +The `let` keyword defines a collection of local declarations, which may be mutually recursive, and which may include type declarations: ``` purescript factorial :: Int -> Int @@ -418,10 +418,10 @@ factorial = The `where` keyword can also be used to introduce local declarations at the end of a value declaration: ``` purescript -factorial :: Number -> Number +factorial :: Int -> Int factorial = go 1 where - go :: Number -> Number -> Number + go :: Int -> Int -> Int go acc 1 = acc go acc n = go (acc * n) (n - 1) ``` @@ -470,10 +470,10 @@ maybeSum a b = do n <- a m <- b let result = n + m - return result + pure result ``` -`maybeSum` takes two values of type ``Maybe Number`` and returns their sum if neither number is `Nothing`. +`maybeSum` takes two values of type ``Maybe Number`` and returns their sum if neither value is `Nothing`. When using `do` notation, there must be a corresponding instance of the `Monad` type class for the return type. @@ -490,6 +490,6 @@ maybeSum a b = a >>= \n -> b >>= \m -> let result = n + m - in return result + in pure result ``` Note: (>>=) is the `bind` function for the `Bind` type as defined in the [Prelude package](https://pursuit.purescript.org/packages/purescript-prelude/2.1.0/docs/Prelude#t:Bind). From a230ff599bbd0e3f447ba024764f5e55f05d04a8 Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Sun, 23 Apr 2017 16:44:26 +0200 Subject: [PATCH 2/9] Update Syntax.md --- language/Syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/Syntax.md b/language/Syntax.md index 9aa3a7ea..ee61c763 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -122,7 +122,7 @@ Numeric literals can be integers (type `Int`) or floating point numbers (type `N ``` purescript 16 :: Int 0xF0 :: Int -16.0 :: Float +16.0 :: Number ``` ### Strings From 9585cc71c7f89360c20f50942f0e754cb025e9b1 Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Mon, 24 Apr 2017 14:11:59 +0200 Subject: [PATCH 3/9] Update Syntax.md --- language/Syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/Syntax.md b/language/Syntax.md index ee61c763..ab30aa63 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -402,7 +402,7 @@ conditional = if 2 > 1 then "ok" else "oops" ## Let and where bindings -The `let` keyword defines a collection of local declarations, which may be mutually recursive, and which may include type declarations: +The `let` keyword introduces a collection of local declarations, which may be mutually recursive, and which may include type declarations: ``` purescript factorial :: Int -> Int From 57183b6c31bd02496c268cbd3bc078e63f4fcf72 Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Mon, 24 Apr 2017 14:22:25 +0200 Subject: [PATCH 4/9] Update Syntax.md --- language/Syntax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/Syntax.md b/language/Syntax.md index ab30aa63..36d31d8e 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -402,7 +402,7 @@ conditional = if 2 > 1 then "ok" else "oops" ## Let and where bindings -The `let` keyword introduces a collection of local declarations, which may be mutually recursive, and which may include type declarations: +`let` expressions introduce a list of local declarations, which may be mutually recursive, and which may include type declarations: ``` purescript factorial :: Int -> Int @@ -415,7 +415,7 @@ factorial = go 1 ``` -The `where` keyword can also be used to introduce local declarations at the end of a value declaration: +`where` clauses can be added at the end of a function declaration, and allow to bind variables that are visible within the surrounding function context: ``` purescript factorial :: Int -> Int From 3a1908b297e9442e4602d12b4f6793fcc9f2b263 Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Mon, 24 Apr 2017 14:26:48 +0200 Subject: [PATCH 5/9] Update Syntax.md --- language/Syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/Syntax.md b/language/Syntax.md index 36d31d8e..72e46969 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -402,7 +402,7 @@ conditional = if 2 > 1 then "ok" else "oops" ## Let and where bindings -`let` expressions introduce a list of local declarations, which may be mutually recursive, and which may include type declarations: +`let` expressions encompass a list of local declarations, which may be mutually recursive, and which may include type declarations: ``` purescript factorial :: Int -> Int From 6b47cd2290bdd337a98a817774386e1c335b7a99 Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Mon, 24 Apr 2017 15:33:12 +0200 Subject: [PATCH 6/9] Update Syntax.md --- language/Syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/Syntax.md b/language/Syntax.md index 72e46969..4be249b6 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -415,7 +415,7 @@ factorial = go 1 ``` -`where` clauses can be added at the end of a function declaration, and allow to bind variables that are visible within the surrounding function context: +`where` clauses can be added at the end of a function declaration, and allow to bind variables that are visible throughout the function: ``` purescript factorial :: Int -> Int From 374c4cd19e20fbc8cf82ee557fa4d026b4f84086 Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Mon, 24 Apr 2017 17:53:23 +0200 Subject: [PATCH 7/9] Update Syntax.md --- language/Syntax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/Syntax.md b/language/Syntax.md index 4be249b6..b527727f 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -402,7 +402,7 @@ conditional = if 2 > 1 then "ok" else "oops" ## Let and where bindings -`let` expressions encompass a list of local declarations, which may be mutually recursive, and which may include type declarations: +The `let` keyword creates an expression with local bindings, which may be mutually recursive, and which may include type declarations: ``` purescript factorial :: Int -> Int @@ -415,7 +415,7 @@ factorial = go 1 ``` -`where` clauses can be added at the end of a function declaration, and allow to bind variables that are visible throughout the function: +The `where` keyword can be used at the end of a value declaration to set up bindings that are visible throughout that value: ``` purescript factorial :: Int -> Int From 412c7425f42a99a38c1f6840ce9880d90cd92725 Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Mon, 24 Apr 2017 18:06:00 +0200 Subject: [PATCH 8/9] Update Syntax.md --- language/Syntax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/Syntax.md b/language/Syntax.md index b527727f..15ea8f30 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -402,7 +402,7 @@ conditional = if 2 > 1 then "ok" else "oops" ## Let and where bindings -The `let` keyword creates an expression with local bindings, which may be mutually recursive, and which may include type declarations: +The let keyword introduces a collection of local declarations, which may be mutually recursive, and which may include type declarations: ``` purescript factorial :: Int -> Int @@ -415,7 +415,7 @@ factorial = go 1 ``` -The `where` keyword can be used at the end of a value declaration to set up bindings that are visible throughout that value: +The where keyword can also be used to introduce local declarations at the end of a value declaration: ``` purescript factorial :: Int -> Int From 6fca26e6a9a1b5854e6b02761b7f7617b857ee4f Mon Sep 17 00:00:00 2001 From: Andreas Thoelke Date: Mon, 24 Apr 2017 18:07:21 +0200 Subject: [PATCH 9/9] Update Syntax.md --- language/Syntax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/Syntax.md b/language/Syntax.md index 15ea8f30..ab30aa63 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -402,7 +402,7 @@ conditional = if 2 > 1 then "ok" else "oops" ## Let and where bindings -The let keyword introduces a collection of local declarations, which may be mutually recursive, and which may include type declarations: +The `let` keyword introduces a collection of local declarations, which may be mutually recursive, and which may include type declarations: ``` purescript factorial :: Int -> Int @@ -415,7 +415,7 @@ factorial = go 1 ``` -The where keyword can also be used to introduce local declarations at the end of a value declaration: +The `where` keyword can also be used to introduce local declarations at the end of a value declaration: ``` purescript factorial :: Int -> Int