Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

Other improvements:
- Updated `README.md` to make the Quick start example runnable (#37 by @dk949)
- Added `purs-tidy` formatter (#36 by @thomashoneyman)

## [v9.0.0](https://github.com/purescript-contrib/purescript-argonaut-traversals/releases/tag/v9.0.0) - 2021-02-26
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ You can use the prisms defined in `Data.Argonaut.Prisms` with functions from the

```js
// FFI file
exports.sampleJson = { "a": { "b" [ 10, 11, 12 ] } }
exports.sampleJson = { "a": { "b": [ 10, 11, 12 ] } }
```

```purs
module Main where

import Prelude

import Effect (Effect)
import Data.Argonaut.Core (Json, jsonParser)
import Data.Argonaut.Core (Json)
import Data.Argonaut.Prisms (_Array, _Number, _Object)
import Data.Maybe (Maybe(..))
import Data.Lens (preview)
Expand All @@ -48,7 +50,7 @@ main :: Effect Unit
main =
-- Walk through an object at the key 'a', then an object at the key 'b', then
-- get the first index of an array as a number.
case preview (_Object <<< ix "a" <<< _Object <<< ix "b" <<< _Array <<< ix 0 <<< _Number) json of
case preview (_Object <<< ix "a" <<< _Object <<< ix "b" <<< _Array <<< ix 0 <<< _Number) sampleJson of
Nothing -> log "nothin' there"
Just v -> log $ "This should be 10.0 " <> show v
```
Expand Down