Skip to content

Add documentation for type holes and language extensions #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions language/Syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 introduces the `ado` keyword:

```purescript
user = ado
name <- read
in { name }
```

These are documented in the [differences from Haskell page](Differences-from-Haskell.md)