Skip to content

Commit

Permalink
Merge pull request #398 from Plutonomicon/website
Browse files Browse the repository at this point in the history
Nix'ify docs website, and check for broken links in CI
  • Loading branch information
L-as authored Mar 27, 2022
2 parents bedf396 + 82c803b commit 14034fb
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake.lock linguist-generated=true
19 changes: 17 additions & 2 deletions docs/DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Looking to contribute to Plutarch? Looking for functionalities that are not curr
- [Lower Level Examples](#lower-level-examples)
- [Extracting `txInfoInputs` from `ScriptContext` manually (UNTYPED)](#extracting-txinfoinputs-from-scriptcontext-manually-untyped)
- [Useful Links](#useful-links)
- [How to build docs](#how-to-build-docs)

</details>

Expand Down Expand Up @@ -58,7 +59,7 @@ Parts of the [Pluto guide](https://github.com/Plutonomicon/pluto/blob/main/GUIDE

## Plutus Core constants (UNSAFE)

> **NOTE**: The following information is almost never necessary with the existence of `pconstant`. Refer to [constant building](./GUIDE.md#constants) and [`PConstant`/`PLift`](./GUIDE.md#pconstant--plift) section of the Plutarch user guide.
> **NOTE**: The following information is almost never necessary with the existence of `pconstant`. Refer to [constant building](Introduction/Plutarch%20Terms/Plutarch%20Constants.md) and [`PConstant`/`PLift`](./Typeclasses/PConstant%20and%20PLift.md) section of the Plutarch user guide.
Often, you will need to build a Plutus core constant. You can do this using `Some` and `ValueOf`. Here's how `pcon PTrue` creates a Plutarch term that actually evaluates to a Plutus core constant representing a boolean:

Expand Down Expand Up @@ -238,7 +239,7 @@ mockCtx =
Right (Program () (Version () 1 0 0) (Constant () (Some (ValueOf data (Constr 0 [List [Constr 0 [Constr 0 [Constr 0 [B ""],I 1],Constr 0 [Constr 0 [Constr 0 [B "\SOH#"],Constr 1 []],Map [],Constr 1 []]]],List [],Map [],Map [],List [],List [],Constr 0 [Constr 0 [Constr 1 [I 1],Constr 1 []],Constr 0 [Constr 1 [I 2],Constr 1 []]],List [],List [],Constr 0 [B ""]])))))
```

> Aside: You can find the definition of `evalWithArgsT` above - [Compiling and Running](./GUIDE.md#compiling-and-running).
> Aside: You can find the definition of `evalWithArgsT` above - [Compiling and Running](./README.md#compiling-and-running).
But we're not done yet! We want `txInfoInputs`. You may have noticed where exactly it is located on the above output. See that `List …`? Inside the outermost `Constr`'s fields? That's our `txInfoInputs`!

Expand Down Expand Up @@ -289,3 +290,17 @@ There's just one element in `txInfoInputs` in this example, and there it is. Of
- [Plutus builtin functions and types](https://playground.plutus.iohkdev.io/doc/haddock//plutus-tx/html/PlutusTx-Builtins-Internal.html)
- [Plutus Core builtin function identifiers, aka `DefaultFun`](https://playground.plutus.iohkdev.io/doc/haddock/plutus-core/html/PlutusCore.html#t:DefaultFun)
- [Plutus Core types, aka `DefaultUni`](https://playground.plutus.iohkdev.io/doc/haddock/plutus-core/html/PlutusCore.html#t:DefaultUni)

# How to build docs

To run the docs locally,

```sh-session
nix run .#docs
```

To build the static HTML site,

```sh-session
nix build .#website
```
2 changes: 1 addition & 1 deletion docs/Introduction/Plutarch Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

When this guide uses the term "Plutarch Type" we explicitly talk about a type of _kind_ `PType`. We will refer to _" types of kind `PType` "_ simply as `PType`s. We explicitly qualify when referring to the _kind_ `PType`.

> Note to beginners: Plutarch uses a language extension called `DataKinds`. This means that there are kinds beyond `Type` (aka `*`). We refer the read to \[[3](./../Concepts.md#references)] for an extended beginner-level introduction to these concepts if desired.
> Note to beginners: Plutarch uses a language extension called `DataKinds`. This means that there are kinds beyond `Type` (aka `*`). We refer the read to \[[3](./../Introduction.md#references)] for an extended beginner-level introduction to these concepts if desired.
`PType` is defined as `type PType = S -> Type`; that is, it is a _kind synonym_ for `S -> Type` (where `S` and `Type` are themselves kinds). This synonym is important to keep in mind because when querying the kind of something like `PBool` in, say, GHCi, we will _not_ see `PType` as the kind. Instead, we get

Expand Down
6 changes: 3 additions & 3 deletions docs/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ f = phoistAcyclic $ plam $ \n ->

The issue here is that the AST is infinitely large. Plutarch will try to traverse this AST and will in the process not terminate, as there is no end to it. In these cases, consider using `pfix`.

Relevant issue: [#19](https://github.com/Plutonomicon/plutarch/issues/19)
Relevant issue: [\#19](https://github.com/Plutonomicon/plutarch/issues/19)

# Couldn't match type `Plutarch.DataRepr.Internal.PUnLabel ...` arising from a use of `pfield` (or `hrecField`, or `pletFields`)

Expand All @@ -68,12 +68,12 @@ Orphan instances! Specifically, in order for those type family applications to f

This happens often with Plutarch ledger API types. If you didn't import `Plutarch.Api.V1.Contexts` (or some other module that imports it), and you're using `pconstant` on a `ScriptContext` - you'll get an error like this. The `PConstant` instance for `ScriptContext` hasn't been imported - so GHC has no idea what `PConstanted ScriptContext` is!

Relevant issue: [#252](https://github.com/Plutonomicon/plutarch/issues/252)
Relevant issue: [\#252](https://github.com/Plutonomicon/plutarch/issues/252)

# Type match errors when using `pfield`/`hrecField` (or `OverloadedRecordDot` to access field)

You might get nonsensical "Couldn't match type" errors when extracting fields. This has to do with GHC incorrectly inferring the return type. Field extraction is meant to be polymorphic in its return type in the sense that it might either return a `Term s (PAsData p)` term, or simply a `Term s p` (automatic `pfromData`). Unfortunately, sometimes this polymorphism makes it harder for GHC to infer the types.

You can fix this by providing an explicit type annotation on _the result_ of `pfield` or `hrecField` (or `OverloadedRecordDot` for field access). Otherwise, you can also explicitly use `pfromData` on the result.

Relevant issue: [#275](https://github.com/Plutonomicon/plutarch/issues/275)
Relevant issue: [\#275](https://github.com/Plutonomicon/plutarch/issues/275)
2 changes: 1 addition & 1 deletion docs/Typeclasses/PConstant and PLift.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,4 @@ deriving via
PConstant (Maybe h)
```

Relevant issue: [#286](https://github.com/Plutonomicon/plutarch/issues/286)
Relevant issue: [\#286](https://github.com/Plutonomicon/plutarch/issues/286)
2 changes: 1 addition & 1 deletion docs/Typeclasses/PIsDataRepr and PDataFields.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mockCtx =
Right (Program () (Version () 1 0 0) (Constant () (Some (ValueOf string "It's minting!"))))
```

> Aside: You can find the definition of `evalWithArgsT` at [Compiling and Running](../GUIDE.md#compiling-and-running).
> Aside: You can find the definition of `evalWithArgsT` at [Compiling and Running](../README.md#compiling-and-running).
## All about extracting fields

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/BASIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Basic examples demonstrating Plutarch usage.

> Note: If you spot any mistakes/have any related questions that this guide lacks the answer to, please don't hesitate to raise an issue. The goal is to have high quality documentation for Plutarch users!
> Aside: Be sure to check out [Compiling and Running](./../GUIDE.md#compiling-and-running) first!
> Aside: Be sure to check out [Compiling and Running](./../README.md#compiling-and-running) first!
# Fibonacci number at given index

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/VALIDATOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Examples of validators and minting policies written in Plutarch.
- [Validator that checks whether a value is present within signatories](#validator-that-checks-whether-a-value-is-present-within-signatories)
- [Using custom datum/redeemer in your Validator](#using-custom-datumredeemer-in-your-validator)

> Aside: Be sure to check out [Compiling and Running](./../GUIDE.md#compiling-and-running) first!
> Aside: Be sure to check out [Compiling and Running](./../README.md#compiling-and-running) first!
# Validator that always succeeds

Expand Down
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Plutarch Guide

See [[README]]
14 changes: 14 additions & 0 deletions docs/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Emanote settings
#
# For list of possible settings and their defaults, see:
# https://github.com/srid/emanote/blob/master/default/index.yaml

template:
# Change this to 'pretty' to use URLs without .html suffix.
urlStrategy: direct
theme: green

page:
siteTitle: Plutarch Guide
headHtml: |
<snippet var="js.prism" />
Loading

0 comments on commit 14034fb

Please sign in to comment.