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
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ shellcheck...........................................(no files to check)Skipped
typos....................................................................Passed
```

To run all the code quality tooling specified in the [pre-commit-check config file](../pre-commit.nix)
To run all the code quality tooling specified in the [pre-commit-check config file](https://github.com/mlabs-haskell/lambda-buffers/blob/main/pre-commit.nix)
2 changes: 1 addition & 1 deletion docs/haskell.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ github:mlabs-haskell/lambda-buffers#lbf-prelude-to-haskell`.

In this chapter, we're going to use the latter option.

Let's now use `lbf-prelude-to-haskell` to process the [Document.lbf](examples/Document.lbf) schema.
Let's now use `lbf-prelude-to-haskell` to process the [Document.lbf](https://github.com/mlabs-haskell/lambda-buffers/tree/main/docs/examples/Document.lbf) schema.

```purescript
module Document
Expand Down
40 changes: 20 additions & 20 deletions docs/plutarch.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ For a full example see [Example](#example).

Writing .lbf schemas with API types intended for Plutarch backend will typically use the following LambdaBuffers schema modules:

1. [Prelude](../libs/lbf-prelude/Prelude.lbf),
2. [Plutus.V1](../libs/lbf-plutus/Plutus/V1.lbf),
3. [Plutus.V2](../libs/lbf-plutus/Plutus/V2.lbf).
1. [Prelude](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-prelude/Prelude.lbf),
2. [Plutus.V1](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus/Plutus/V1.lbf),
3. [Plutus.V2](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus/Plutus/V2.lbf).

Take a look at [Example.lbf](./plutarch/api/Example.lbf) schema as an example.
Take a look at [Example.lbf](https://github.com/mlabs-haskell/lambda-buffers/tree/main/docs/plutarch/api/Example.lbf) schema as an example.

## Haskell libraries

The necessary LambdaBuffers runtime libraries a typical Plutarch project needs when working with LambdaBuffers:

1. [lbr-plutarch](../runtimes/haskell/lbr-plutarch) a Haskell runtime library necessary for working with `lbf-xyz` libraries.
2. [lbf-prelude-plutarch](../libs/lbf-prelude) that contains the [LambdaBuffers Prelude](../libs/lbf-prelude) schema library generated by LambdaBuffers.
3. [lbf-plutus-plutarch](../libs/lbf-plutus) that contains the [LambdaBuffers Plutus](../libs/lbf-plutus) schema library generated by LambdaBuffers.
1. [lbr-plutarch](https://github.com/mlabs-haskell/lambda-buffers/tree/main/runtimes/haskell/lbr-plutarch) a Haskell runtime library necessary for working with `lbf-xyz` libraries.
2. [lbf-prelude-plutarch](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-prelude) that contains the [LambdaBuffers Prelude](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-prelude) schema library generated by LambdaBuffers.
3. [lbf-plutus-plutarch](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus) that contains the [LambdaBuffers Plutus](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus) schema library generated by LambdaBuffers.

Of course, additional imports for Plutarch libraries are also necessary [plutarch](https://github.com/Plutonomicon/plutarch-plutus) and optionally [plutarch-extra](https://github.com/Plutonomicon/plutarch-plutus/plutarch-extra).
Of course, additional imports for Plutarch libraries are also necessary [plutarch](https://github.com/Plutonomicon/plutarch-plutus) and optionally [plutarch-extra](https://github.com/Plutonomicon/plutarch-plutus/tree/master/plutarch-extra).

For a full example see [Example](#example).

Expand Down Expand Up @@ -99,10 +99,10 @@ import Plutarch.Api.V1 ()
import Plutarch.Api.V2 ()
```

1. LambdaBuffers.Plutus.V1.Plutarch is a module generated from [Plutus.V1](../libs/lbf-plutus/Plutus/V1.lbf) LambdaBuffers schema and provided by the [lbf-plutus-plutarch](../libs/lbf-plutus) runtime library.
2. LambdaBuffers.Plutus.V2.Plutarch is a module generated from [Plutus.V2](../libs/lbf-plutus/Plutus/V2.lbf) LambdaBuffers schema and provided by the [lbf-plutus-plutarch](../libs/lbf-plutus) runtime library.
3. LambdaBuffers.Prelude.Plutarch is a module generated from [Prelude](../libs/lbf-prelude/Prelude.lbf) LambdaBuffers schema and provided by the [lbf-prelude-plutarch](../libs/lbf-prelude) runtime library.
4. LambdaBuffers.Runtime.Plutarch is a module provided by the [lbr-plutarch](../runtimes/haskell/lbr-plutarch) runtime library.
1. LambdaBuffers.Plutus.V1.Plutarch is a module generated from [Plutus.V1](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus/Plutus/V1.lbf) LambdaBuffers schema and provided by the [lbf-plutus-plutarch](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus) runtime library.
2. LambdaBuffers.Plutus.V2.Plutarch is a module generated from [Plutus.V2](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus/Plutus/V2.lbf) LambdaBuffers schema and provided by the [lbf-plutus-plutarch](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus) runtime library.
3. LambdaBuffers.Prelude.Plutarch is a module generated from [Prelude](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-prelude/Prelude.lbf) LambdaBuffers schema and provided by the [lbf-prelude-plutarch](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-prelude) runtime library.
4. LambdaBuffers.Runtime.Plutarch is a module provided by the [lbr-plutarch](https://github.com/mlabs-haskell/lambda-buffers/tree/main/runtimes/haskell/lbr-plutarch) runtime library.

> Generated Plutarch module for a LambdaBuffers schema `Foo/Bar.lbf` (ie. `Foo.Bar`) is stored at `Foo/Bar/Plutarch.hs`

Expand Down Expand Up @@ -147,15 +147,15 @@ For example the `Foo` record defined above would have no difference in Plutarch
prod Foo = Integer Bool
```

The Plutarch backend doesn't support the use of `Char`, `Text`, `Bytes` (there's a Plutus.V1.Bytes), `Set` and `Map` (there's a Plutus.V1.Map) from [LambdaBuffers Prelude](../libs/lbf-prelude/Prelude.lbf) module.
The Plutarch backend doesn't support the use of `Char`, `Text`, `Bytes` (there's a Plutus.V1.Bytes), `Set` and `Map` (there's a Plutus.V1.Map) from [LambdaBuffers Prelude](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-prelude/Prelude.lbf) module.

## Plutarch

### Type definition mapping

Plutarch backend supports all types from the [LambdaBuffers Plutus](../libs/lbf-plutus) schema library, as to enable full featured Plutus script development.
Plutarch backend supports all types from the [LambdaBuffers Plutus](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-plutus) schema library, as to enable full featured Plutus script development.

Additionally, it also supports some types from the [LambdaBuffers Prelude](../libs/lbf-prelude) schema library, namely `Bool`, `Integer`, `Maybe`, `Either` and `List`.
Additionally, it also supports some types from the [LambdaBuffers Prelude](https://github.com/mlabs-haskell/lambda-buffers/tree/main/libs/lbf-prelude) schema library, namely `Bool`, `Integer`, `Maybe`, `Either` and `List`.

```lbf
module Foo
Expand Down Expand Up @@ -318,7 +318,7 @@ All generated types have a PShow instance derived using the internal Plutarch de

## Example

Let work through the [Plutarch example](./plutarch) available in the repo.
Let work through the [Plutarch example](https://github.com/mlabs-haskell/lambda-buffers/tree/main/docs/plutarch) available in the repo.

First, please check the [Getting started](getting-started.md) guide on how to prepare to work with the repo and setup Nix.

Expand All @@ -340,8 +340,8 @@ lambda-buffers/docs/plutarch ❯ find

The salient bits we should focus on are:

1. The LambdaBuffers .lbf schema in [./api/Example.lbf](./plutarch/api/Example.lbf) that describes the API types used by our little program,
2. The Haskell Plutarch program in [./app/Example.hs](./plutarch/app/Example.hs) that works with the API types.
1. The LambdaBuffers .lbf schema in [./api/Example.lbf](https://github.com/mlabs-haskell/lambda-buffers/tree/main/docs/plutarch/api/Example.lbf) that describes the API types used by our little program,
2. The Haskell Plutarch program in [./app/Example.hs](https://github.com/mlabs-haskell/lambda-buffers/tree/main/docs/plutarch/app/Example.hs) that works with the API types.

To inspect the generated library:

Expand All @@ -359,7 +359,7 @@ autogen/LambdaBuffers/Example/Plutarch.hs

However, it's not expected for users to need to do this. If you have any issue please reach out.

Inspecting the [Cabal file](./plutarch/plutarch-example.cabal) shows the standard runtime libraries we need:
Inspecting the [Cabal file](https://github.com/mlabs-haskell/lambda-buffers/tree/main/docs/plutarch/plutarch-example.cabal) shows the standard runtime libraries we need:

```shell
lambda-buffers/docs/plutarch ❯ cabal info .
Expand Down Expand Up @@ -388,4 +388,4 @@ lambda-buffers/docs/plutarch ❯ cabal run
"Friends, peace and love!!!"
```

Take a look at the [Example.hs](./plutarch/app/Example.hs) to see how generated types are used, namely how they are constructed with `pcon` and deconstructed with `pmatch` (or `pmatchC`).
Take a look at the [Example.hs](https://github.com/mlabs-haskell/lambda-buffers/tree/main/docs/plutarch/app/Example.hs) to see how generated types are used, namely how they are constructed with `pcon` and deconstructed with `pmatch` (or `pmatchC`).
2 changes: 1 addition & 1 deletion docs/purescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ github:mlabs-haskell/lambda-buffers#lbf-prelude-to-purescript`.

In this chapter, we're going to use the latter option.

Let's now use `lbf-prelude-to-purescript` to process the [Document.lbf](examples/Document.lbf) schema
Let's now use `lbf-prelude-to-purescript` to process the [Document.lbf](https://github.com/mlabs-haskell/lambda-buffers/blob/main/docs/examples/Document.lbf) schema

```purescript
module Document
Expand Down