Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbecich committed Jan 4, 2024
1 parent 2d6a6e2 commit 3be53bf
Showing 1 changed file with 36 additions and 12 deletions.
48 changes: 36 additions & 12 deletions example/readme.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
# Purescript Bridge example

This project demonstrates the libraries Purescript Bridge and [`purescript-argonaut-aeson-generic`](https://pursuit.purescript.org/packages/purescript-argonaut-aeson-generic) ([GitHub](https://github.com/coot/purescript-argonaut-aeson-generic)).
This project demonstrates the libraries Purescript Bridge and [`input-output-hk/purescript-bridge-json-helpers`](https://github.com/input-output-hk/purescript-bridge-json-helpers.git).

It needs Purescript 0.15.
It does not use [`purescript-argonaut-aeson-generic`](https://pursuit.purescript.org/packages/purescript-argonaut-aeson-generic) ([GitHub](https://github.com/coot/purescript-argonaut-aeson-generic)).

The Haskell type `Foo`, in `src/Types.hs`, is generated for Purescript by Purescript Bridge. Purescript Argonaut Aeson Generic is used to decode and encode this type, client-side.
The Haskell type `Foo`, in `src/Types.hs`, is generated for Purescript by Purescript Bridge. `purescript-bridge-json-helpers` is used to decode and encode this type, client-side.

In this directory:
# Dependencies
## Nix
The `nix develop` shell will provide Purescipt 0.15 and Spago.
## Without Nix
You must install Purescript 0.15 and Spago.

- Generate the Javascript bundle:
# Running the example
- Enter the `example` directory

```spago bundle-app --to static/index.js```
- With Nix:
```
nix run
```

- `cabal run example`
- Or without Nix:
```
cabal run example
```

- Open [http://localhost:8080/index.html](http://localhost:8080/index.html)

- Open the browser's developer console and look for the message received:

```
Foo message: Hello Foo number: 123 Foo list length: 11
```
Expand All @@ -28,10 +38,24 @@ Foo message: Hello Foo number: 123 Foo list length: 11
Foo message: Hola Foo number: 124 Foo list length: 22
```

----------------
# Updating the Purescript Bridge
- Enter the `example` directory

- Regenerate the Purescript Bridge types:
```
cabal run generate-purescript
```

- Generate the Javascript bundle:
```
spago bundle-app --to static/index.js
```
- or:
```
spago bundle-app --watch --to static/index.js
```

Regenerate the Purescript for the bridge type `Foo` with `cabal run generate-purescript`.
- Restart the server

----------------

This Purescript Discourse thread assisted me: https://discourse.purescript.org/t/latest-and-greatest-haskell-purescript-serialization/1640
More discussion: https://discourse.purescript.org/t/latest-and-greatest-haskell-purescript-serialization/1640

0 comments on commit 3be53bf

Please sign in to comment.