Skip to content

Commit 71161ba

Browse files
authored
chore: typos on getting started guide
1 parent 571210c commit 71161ba

File tree

1 file changed

+47
-36
lines changed

1 file changed

+47
-36
lines changed

docs/getting-started.md

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
An instance of `CEMScript` revolves primarily around the following two type classes.
66

77
Here, `script` is an uninhabited type that is used to
8-
tie together the different types associated with an instance of CEMScript.
8+
tie together the different types associated with an instance of CEMScript.on
99

1010
`CEMScriptTypes` defines those types:
1111

@@ -37,8 +37,8 @@ class
3737
-- | The crux part - a map that defines constraints for each transition via DSL.
3838
transitionSpec :: CEMScriptSpec False script
3939

40-
-- | Optional Plutus script to calculate things, whic can be used in the cases
41-
-- when CEM constrainsts and/or inlining Plutarch functions are not expresisble
40+
-- | Optional Plutus script to calculate things, which can be used in the cases
41+
-- when CEM constraints and/or inlining Plutarch functions are not expressible
4242
-- enough.
4343
transitionComp ::
4444
Maybe
@@ -61,11 +61,11 @@ type CEMScriptSpec resolved script =
6161

6262
### Spine
6363

64-
Spine of an ADT is a sum type that is just a list of its constructors.
64+
The spine of an ADT is a sum type that is just a list of its constructors.
6565

66-
`HasSpine` type class maps from an ADT to its Spine type and:
66+
`HasSpine` type class maps from an ADT to its Spine type and:
6767

68-
- associates the type to its Spine type through a type family
68+
- associates the type to its Spine type through a type family
6969
- defines a function that translates an instance of the type to an instance of the spine type
7070

7171
```haskell
@@ -75,12 +75,12 @@ class HasSpine sop where
7575
getSpine :: sop -> Spine sop
7676
```
7777

78-
We provide a function `deriveSpine` to automatically derive `HasSpine` using template haskell.
78+
Using the Template Haskell, we provide a function `deriveSpine` to automatically derive `HasSpine`.
7979

8080
### DSL
8181

8282
When writing `CEMScript` transitions, we start by describing constraints
83-
at a high level using a DSL that consistes of the following types:
83+
at a high level using a DSL that consists of the following types:
8484

8585
#### TxConstraint
8686

@@ -92,8 +92,10 @@ data TxConstraint (resolved :: Bool) script where
9292
`TxConstraint` is a GADT (Generalized Algebraic Data Type) parameterized by two things:
9393

9494
1. **`resolved`**: A Boolean type flag (usually `True` or `False`) indicating whether the constraint is in a "resolved" form.
95-
In on-chain code, `resolved` will be `False`, representing the actual computation thats going to take place. In off-chain code, `resolved` will be `True`, which is used to derive a valid transaction from a list of `TxConstraint`s. See the Off-chain machinery section for more details on how this works.
96-
2. **`script`**: A phantom type parameter indicating which CEMScript (state machine) the constraints belong to.
95+
In on-chain code, `resolved` will be `False`, representing the actual computation thats going to take place.
96+
In off-chain code, `resolved` will be `True`, which is used to derive a valid transaction from a list of `TxConstraint`s.
97+
See the Off-chain machinery section for more details on how this works.
98+
3. **`script`**: A phantom type parameter indicating which CEMScript (state machine) the constraints belong to.
9799

98100
See the reference section for a full reference of `TxConstraint`.
99101

@@ -102,9 +104,10 @@ See the reference section for a full reference of `TxConstraint`.
102104
`ConstraintDSL script value` is a GADT that represents a symbolic expression in the DSL.
103105

104106
- `script` is a phantom type parameter, just like in `TxConstraint`.
105-
- `value` is the type of the what this expression will resolve to during runtime.
107+
- `value` is the type of what this expression will resolve during runtime.
106108

107-
`ConstraintDSL` allows us to reference parts of the state machine's parameters, the current state, the transition arguments, and so forth.
109+
`ConstraintDSL` allows us to reference parts of the state machine's parameters,
110+
the current state, the transition arguments, and so forth.
108111

109112
It also lets us perform checks (like equality) and apply transformations (like lifting a Plutarch function).
110113

@@ -122,7 +125,7 @@ type family DSLPattern (resolved :: Bool) script value where
122125
DSLPattern True _ value = Void
123126
```
124127

125-
These are both type level wrappers over `ConstraintDSL`.
128+
These are both type-level wrappers over `ConstraintDSL`.
126129

127130
The type parameter `resolved` will be False for on-chain code, while it will be True for off-chain code.
128131

@@ -179,7 +182,7 @@ data ResolvedTx = MkResolvedTx
179182

180183
```
181184

182-
`resolveTx` is the primary entrypoint for off-chain code.
185+
`resolveTx` is the primary entry point for off-chain code.
183186
It accepts a `TxSpec`, which consists of a list of actions and a signer,
184187
and produces a `ResolvedTx`, which is all the information needed to construct
185188
a transaction thats ready to be submitted to the chain.
@@ -188,10 +191,10 @@ Here’s a rough outline of how it works:
188191

189192
- For each `Transition` in the list of actions
190193
- Find the corresponding transition in the `transitionSpec`
191-
- If the transition spec contains a `TxFan In SameScript` , check the current on-chain state is the same a required by the constraint.
192-
- Convert the `[TxConstraint (resolved :: False)]` of the `Transition` to `[TxConstraint (resolved :: True)]` by invoking `compileConstraint` .
194+
- If the transition spec contains a `TxFan In SameScript`, check the current on-chain state is the same as required by the constraint.
195+
- Convert the `[TxConstraint (resolved :: False)]` of the `Transition` to `[TxConstraint (resolved :: True)]` by invoking `compileConstraint`.
193196

194-
This evaluates all the `DSLValue _ value` expressions and resolve it to a value of type `value`.
197+
This evaluates all the `DSLValue _ value` expressions and resolves it to a value of type `value`.
195198

196199
The following variants of `TxConstraint`
197200

@@ -320,12 +323,12 @@ data TxConstraint (resolved :: Bool) script
320323
Ensure
321324

322325
- The sum of input utxos belonging to `user` is greater than `inValue`
323-
- The sume of output utxos belonging to `user` is greater than `outValue`
326+
- The sum of output utxos belonging to `user` is greater than `outValue`
324327
- `MainSignerNoValue address` Ensure that the given address is part of the transaction signatories.
325328
- `Error message` Output `message` using `ptrace` as an error message.
326329
- `If`
327330
- Evaluate the condition and resolve to the `TxConstraint` in the then branch or the else branch.
328-
- `MatchBySpine pattern map` Evaluate pattern and execute the corresponding action from `map`
331+
- `MatchBySpine pattern map` Evaluate the pattern and execute the corresponding action from `map`
329332
- `map` Map from `Spine` to `TxConstraint`
330333

331334
In addition to the above, CEMScript provides the following helper functions to create `TxConstraint`s
@@ -343,9 +346,9 @@ byFlagError flag message = If flag (Error message) Noop
343346

344347
```
345348

346-
- `cNot` invert a boolean
347-
- `offchainOnly` execute only on chain. Resolve to `Noop` off chain.
348-
- `byFlagError` evaluate to `Error message` if `flag` evaluates to true.
349+
- `cNot` inverts a boolean
350+
- `offchainOnly` executes only on chain. Resolve to `Noop` off chain.
351+
- `byFlagError` evaluates to `Error message` if `flag` evaluates to true.
349352

350353
### ConstraintDSL
351354

@@ -371,7 +374,7 @@ data ConstraintDSL script value where
371374
-- Primitives
372375

373376
-- A wildcard pattern that matches any value.
374-
-- Used in pattern matching contexts where the actual value is irrelevant.
377+
-- Used in pattern-matching contexts where the actual value is irrelevant.
375378
Anything :: ConstraintDSL script x
376379
-- Compare two DSL values
377380
Eq :: (..) => ConstraintDSL script x -> ConstraintDSL script x -> ConstraintDSL script Bool
@@ -415,7 +418,7 @@ cMinLovelace = cMkAdaOnlyValue $ Pure 3_000_000
415418
(@==) = Eq
416419
```
417420

418-
The following are lifted versions of plutrach operators
421+
The following are lifted versions of Plutarch operators
419422

420423
```haskell
421424
(@<=) -- #<=
@@ -438,8 +441,8 @@ The following are lifted versions of plutrach operators
438441

439442
### How to define a script
440443

441-
- Define an empty type for your script: `data MyScript` , where MyScript can be any name.
442-
- Define a `CEMScript` instance for it by providing `Params`, `State`, `Transition`, `transitionSpec` and optionally `transitionComp`.
444+
- Define an empty type for your script: `data MyScript`, where MyScript can be any name.
445+
- Define a `CEMScript` instance for it by providing `Params`, `State`, `Transition`, `transitionSpec`, and optionally `transitionComp`.
443446
- Do Template Haskell derivations (`deriveCEMAssociatedTypes`) to generate data and spine instances for pattern matching.
444447
- Invoke the `compileCEM` function (e.g., `$(compileCEM True ''MyScript)`) to process the DSL specification, compile optional `transitionComp` code, and produce a `CEMScriptCompiled` instance.
445448
- This generates an instance of `CEMScriptCompiled` for your script type.
@@ -449,13 +452,15 @@ The following are lifted versions of plutrach operators
449452

450453
#### Setup: The Types
451454

452-
First we define a type to denote our script. Its an uninhabited type, it cant be constructed. Its only used as a tag for connecting different type classes together.
455+
First, we define a type to denote our script. Its an uninhabited type, it cant be constructed.
456+
Its only used as a tag for connecting all instances of type classes together.
453457

454458
```haskell
455459
data SimpleAuction
456460
```
457461

458-
We define a type for the read-only state of our script. This state cant be modified once created. This becomes the `Params` associated type of the `CEMScript` typeclass.
462+
We define a type for the read-only state of our script. This state cant be modified once created.
463+
This becomes the `Params` associated type of the `CEMScript` type class.
459464

460465
```haskell
461466
data SimpleAuctionParams = MkAuctionParams
@@ -465,7 +470,7 @@ data SimpleAuctionParams = MkAuctionParams
465470
deriving stock (Prelude.Eq, Prelude.Show)
466471
```
467472

468-
We define a type for the evolving state of our script. This becomes the `State` associated type of the `CEMScript` typeclass.
473+
We define a type for the evolving state of our script. This becomes the `State` associated type of the `CEMScript` type class.
469474

470475
```haskell
471476
data Bid = MkBid
@@ -487,7 +492,7 @@ data SimpleAuctionState
487492
deriving stock (Prelude.Eq, Prelude.Show)
488493
```
489494

490-
Lastly, we define a type for the state transitions of our script. This becomes the `Transition` associated type of the `CEMScript` typeclass.
495+
Lastly, we define a type for the state transitions of our script. This becomes the `Transition` associated type of the `CEMScript` type class.
491496

492497
```haskell
493498
data SimpleAuctionTransition
@@ -501,7 +506,10 @@ data SimpleAuctionTransition
501506
deriving stock (Prelude.Eq, Prelude.Show)
502507
```
503508

504-
We can now define an instance of the `CEMScriptTypes` for `SimpleAuction` . `CEMScriptTypes` is a super class of `CEMScript`, which just includes the associated types. By defining the associated types separately, we can use the `deriveCEMAssociatedTypes` template haskell function to generate some boilerplate.
509+
We can now define an instance of the `CEMScriptTypes` for `SimpleAuction`.
510+
`CEMScriptTypes` is a superclass of `CEMScript`, which just includes the associated types.
511+
By defining the associated types separately, we can use the `deriveCEMAssociatedTypes`
512+
Template Haskell function to generate some boilerplate.
505513

506514
```haskell
507515
instance CEMScriptTypes SimpleAuction where
@@ -512,9 +520,11 @@ instance CEMScriptTypes SimpleAuction where
512520
$(deriveCEMAssociatedTypes False ''SimpleAuction)
513521
```
514522

515-
`deriveCEMAssociatedTypes` just executes `derivePlutusSpine` for all three of the associated types. But it can only do that if all the members of a type have a `HasPlutusSpine` implementation. This is why we need to do `derivePlutusSpine` for the `Bid` type ourselves.
523+
`deriveCEMAssociatedTypes` just executes `derivePlutusSpine` for all three of the associated types.
524+
But it can only do that if all the members of a type have a `HasPlutusSpine` implementation.
525+
This is why we need to do `derivePlutusSpine` for the `Bid` type ourselves.
516526

517-
The boolean argument to `deriveCEMAssociatedTypes` is unused for now, and it is recommended to use a value of `False` .
527+
The boolean argument to `deriveCEMAssociatedTypes` is unused for now, and it is recommended to use a value of `False`.
518528

519529
#### Implementation
520530

@@ -524,13 +534,14 @@ To implement the logic of our script, we define an instance of `CEMScript` for o
524534
instance CEMScript SimpleAuction where
525535
```
526536

527-
We provide a value for `compilationConfig` , which at the moment contains only a prefix for error codes to tell errors from different programs apart.
537+
We provide a value for `compilationConfig`, which at the moment contains
538+
only a prefix for error codes to tell errors from different programs apart.
528539

529540
```haskell
530541
compilationConfig = MkCompilationConfig "AUC"
531542
```
532543

533-
Next comes the meat of the script: `transitionSpec` . This is where we define state transitions
544+
Next comes the meat of the script: `transitionSpec`. This is where we define state transitions
534545

535546
We create a Map of `Spine (Transition script)``[TxConstraint False script]`
536547

@@ -556,7 +567,7 @@ auctionValue = cMinLovelace @<> ctxParams.lot
556567

557568
We make extensive use of `OverloadedRecordDot` and custom `HasField` instances to make accessing the fields of the params and state values ergonomic.
558569

559-
Let’s examine each of the entries of the map in detail.
570+
Let’s examine each of the entries in the map in detail.
560571

561572
1. Create
562573

0 commit comments

Comments
 (0)