Skip to content

Commit

Permalink
Records: Property accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentpayot committed Oct 19, 2023
1 parent 36cc494 commit 97ca192
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ toPerson3 =
{ name: _, age: _ } -- equivalent to `\name age -> { name, age }` (types inferred by the signature)
```

### Property Accessors
### Property accessors

In PureScript `(_ + 5)` is the same as `(\n -> n + 5)`, so `(_.prop)` is the same as `(\r -> r.prop)`.

```purs
_.age myPerson -- 30
_.address.street myPerson -- "Main Street"
```

### Destructuring
Expand Down Expand Up @@ -244,12 +245,6 @@ foo arg1 arg2 =
baz s = "Hi " <> s <> "! "
```

## Underscore in lambdas

The underscore symbol `_` can be used in functions when you don't want to give the parameter a name.

`(_ + 10)` is the same as `(\n -> n + 10)`

## Guards

When using patterns to define a function at the top level, guards appear after all patterns:
Expand Down

0 comments on commit 97ca192

Please sign in to comment.