From 5b5aada470c84839984729fdcb498eb38730d8b8 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Sat, 1 Feb 2025 12:06:29 +0000 Subject: [PATCH 1/2] Add documentation for type holes and language extensions --- language/Syntax.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/language/Syntax.md b/language/Syntax.md index 953acbc..8a1e159 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -670,3 +670,30 @@ maybeSum a b = ``` In practice, you will usually be using [`bind` from the Prelude](https://pursuit.purescript.org/packages/purescript-prelude/docs/Control.Bind#v:bind), but the desugaring will use whichever `bind` is in scope. When using `bind` from the Prelude, there must be an instance of the `Monad` type class for the return type. + +## Type holes + +If you’re not sure of a type in a type signature, you can write a type "hole" consisting of a question mark followed by a lowercase name. The compiler will generate an error and tell you what type it inferred: + +```purescript +add x = 1 + ?x +``` + +```txt +add x = 1 + ?x + ^^ +Hole 'x' has the inferred type + Int +``` + +## Language extensions + +There are some additional keywords that are defined in language extensions for example `applicative do notation`: + +```purescript +user = ado + name <- read + in { name } +``` + +These are documented in the [differences from Haskell page](Differences-from-Haskell.md) From db4a1437a75138fc63cf836b41b122bc1c9dfce1 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz Date: Sat, 1 Feb 2025 12:12:15 +0000 Subject: [PATCH 2/2] Simplify ado reference --- language/Syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/Syntax.md b/language/Syntax.md index 8a1e159..04da7bd 100644 --- a/language/Syntax.md +++ b/language/Syntax.md @@ -688,7 +688,7 @@ Hole 'x' has the inferred type ## Language extensions -There are some additional keywords that are defined in language extensions for example `applicative do notation`: +There are some additional keywords that are defined in language extensions for example applicative do notation introduces the `ado` keyword: ```purescript user = ado