Skip to content

Commit c5a3ea8

Browse files
committed
Merge branch 'main' of github.com:mlabs-haskell/lambda-buffers into szg251/darwin
2 parents 6bdab02 + b1036b8 commit c5a3ea8

File tree

222 files changed

+26926
-13839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+26926
-13839
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ competitors if your project requires:
2020
1. _Parameterized Data Types_ (aka. type functions): Unlike ProtoBuffers or
2121
JSON Schema, LambdaBuffers allows users to define algebraic data types which
2222
take type variable arguments. If your project's domain is most accurately
23-
represented by parameterized data types, LamdaBuffers may be a good choice
23+
represented by parameterized data types, LambdaBuffers may be a good choice
2424
for your needs.
2525

2626
2. _Opaque Types_: Almost every competing schema language provides users a
@@ -41,7 +41,7 @@ competitors if your project requires:
4141
productively make use of the generated types. While LambdaBuffers is still a
4242
work-in-progress, we expect that, upon completion, an extensive test suite
4343
will provide a high degree of assurance that the instances/methods generated
44-
by the LamdaBuffers code generator behave identically.
44+
by the LambdaBuffers code generator behave identically.
4545

4646
## Documentation
4747

api/build.nix

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,41 @@
11
{ inputs, ... }:
22
{
3-
perSystem = { pkgs, system, config, ... }:
3+
perSystem = { pkgs, system, config, inputs', ... }:
44
let
5-
pbnix-lib = inputs.protobufs-nix.lib.${system};
5+
proto-nix = inputs.proto-nix.lib.${system};
66
in
77
rec {
88

99
devShells.dev-api = pkgs.mkShell {
1010
name = "protos-env";
11-
buildInputs = [
12-
pkgs.protobuf
13-
pkgs.haskellPackages.proto-lens-protoc
14-
pkgs.protoc-gen-doc
15-
] ++ config.settings.shell.tools;
16-
11+
inputsFrom = [ inputs'.proto-nix.devShells.dev-proto-nix ];
1712
shellHook = config.settings.shell.hook;
1813
};
1914

2015
packages = {
21-
lambda-buffers-lang-hs-pb = pbnix-lib.haskellProto {
22-
inherit pkgs;
16+
lambda-buffers-lang-hs-pb = proto-nix.haskellProto {
2317
src = ./.;
24-
proto = "lang.proto";
18+
protos = [ "lang.proto" ];
2519
cabalPackageName = "lambda-buffers-lang-pb";
2620
};
2721

28-
lambda-buffers-compiler-hs-pb = pbnix-lib.haskellProto {
29-
inherit pkgs;
22+
lambda-buffers-compiler-hs-pb = proto-nix.haskellProto {
3023
src = ./.;
31-
proto = "compiler.proto";
24+
protos = [ "compiler.proto" ];
3225
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
3326
cabalPackageName = "lambda-buffers-compiler-pb";
3427
};
3528

36-
lambda-buffers-codegen-hs-pb = pbnix-lib.haskellProto {
37-
inherit pkgs;
29+
lambda-buffers-codegen-hs-pb = proto-nix.haskellProto {
3830
src = ./.;
39-
proto = "codegen.proto";
31+
protos = [ "codegen.proto" ];
4032
cabalBuildDepends = [ packages.lambda-buffers-lang-hs-pb ];
4133
cabalPackageName = "lambda-buffers-codegen-pb";
4234
};
4335

44-
lambda-buffers-api-docs = pkgs.stdenv.mkDerivation {
36+
lambda-buffers-api-docs = proto-nix.docProto {
4537
src = ./.;
46-
name = "lambdabuffers-api-docs";
47-
buildInputs = [
48-
pkgs.protobuf
49-
];
50-
buildPhase = ''
51-
mkdir $out;
52-
protoc --plugin=${pkgs.protoc-gen-doc}/bin/protoc-gen-doc lang.proto compiler.proto codegen.proto --doc_out=$out --doc_opt=markdown,api.md;
53-
'';
38+
protos = [ "lang.proto" "compiler.proto" "codegen.proto" ];
5439
};
5540
};
5641
};

api/lang.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ message SourcePosition {
2727

2828
/* Type term
2929
30-
A type term that ocurrs in bodies of type definitions (message TyDef):
30+
A type term that occurs in bodies of type definitions (message TyDef):
3131
3232
```lbf
3333
sum Maybe a = Just a | Nothing
@@ -146,7 +146,7 @@ message TyName {
146146

147147
/* Module name */
148148
message ModuleName {
149-
// Parts of the module name denoting a hierarchichal namespace.
149+
// Parts of the module name denoting a hierarchical namespace.
150150
repeated ModuleNamePart parts = 1;
151151
// Source information.
152152
SourceInfo source_info = 2;

docs/build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ _: {
44
devShells.dev-docs = pkgs.mkShell {
55
name = "docs-env";
66
packages = [ pkgs.mdbook ];
7-
shellHook = config.pre-commit.installationScript;
7+
shellHook = config.settings.shell.hook;
88
};
99

1010
packages.lambda-buffers-book = pkgs.stdenv.mkDerivation {

docs/feedback/interview-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
1. R. would like it to be seamless. R. mentions:
4747
1. Auto generate modules
4848
2. pre-commit hooks
49-
3. itterate quickly
49+
3. iterate quickly
5050
4. Nix integration is very important
5151
5. Not running commands.
5252
6. Watch function for the compiler.

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ shellcheck...........................................(no files to check)Skipped
6969
typos....................................................................Passed
7070
```
7171

72-
To run all the code quality tooling specified in the [pre-commit-check config file](../pre-commit.nix)
72+
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)

docs/haskell.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ github:mlabs-haskell/lambda-buffers#lbf-prelude-to-haskell`.
1919

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

22-
Let's now use `lbf-prelude-to-haskell` to process the [Document.lbf](examples/Document.lbf) schema.
22+
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.
2323

2424
```purescript
2525
module Document
@@ -108,7 +108,7 @@ $ ghc autogen/LambdaBuffers/Document.hs
108108

109109
## Sum types
110110

111-
The types `Author`, `Reviewer`, and `RichContent` have been declared as sum types in the LamdaBuffers schema using the `sum` keyword.
111+
The types `Author`, `Reviewer`, and `RichContent` have been declared as sum types in the LambdaBuffers schema using the `sum` keyword.
112112

113113
As we can see, nothing too surprising here, all the `sum` types become `data`
114114
in Haskell.
@@ -119,7 +119,7 @@ quote) to the defined constructor names as to make sure they are unique.
119119
## Product types
120120

121121
The type `RichDocument` have been declared as a product type in the
122-
LamdaBuffers schema using the `prod` keyword.
122+
LambdaBuffers schema using the `prod` keyword.
123123

124124
They become Haskell `newtype` if they have a single type in their body, otherwise they are `data`.
125125

@@ -128,7 +128,7 @@ Note that the constructor has the same name as the type.
128128
## Record types
129129

130130
The types `Document` and `Chapter` have been declared as record types in the
131-
LamdaBuffers schema using the `record` keyword.
131+
LambdaBuffers schema using the `record` keyword.
132132

133133
Like with product types, they become Haskell `newtype` if they have a single
134134
type in their body, otherwise they are `data`.

docs/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ competitors if your project requires:
1818
1. _Parameterized Data Types_ (aka. type functions): Unlike ProtoBuffers or
1919
JSON Schema, LambdaBuffers allows users to define algebraic data types which
2020
take type variable arguments. If your project's domain is most accurately
21-
represented by parameterized data types, LamdaBuffers may be a good choice
21+
represented by parameterized data types, LambdaBuffers may be a good choice
2222
for your needs.
2323

2424
2. _Opaque Types_: Almost every competing schema language provides users a
@@ -39,4 +39,4 @@ competitors if your project requires:
3939
productively make use of the generated types. While LambdaBuffers is still a
4040
work-in-progress, we expect that, upon completion, an extensive test suite
4141
will provide a high degree of assurance that the instances/methods generated
42-
by the LamdaBuffers code generator behave identically.
42+
by the LambdaBuffers code generator behave identically.

docs/plutarch.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ For a full example see [Example](#example).
4343

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

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

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

5252
## Haskell libraries
5353

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

56-
1. [lbr-plutarch](../runtimes/haskell/lbr-plutarch) a Haskell runtime library necessary for working with `lbf-xyz` libraries.
57-
2. [lbf-prelude-plutarch](../libs/lbf-prelude) that contains the [LambdaBuffers Prelude](../libs/lbf-prelude) schema library generated by LambdaBuffers.
58-
3. [lbf-plutus-plutarch](../libs/lbf-plutus) that contains the [LambdaBuffers Plutus](../libs/lbf-plutus) schema library generated by LambdaBuffers.
56+
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.
57+
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.
58+
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.
5959

60-
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).
60+
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).
6161

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

@@ -99,10 +99,10 @@ import Plutarch.Api.V1 ()
9999
import Plutarch.Api.V2 ()
100100
```
101101

102-
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.
103-
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.
104-
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.
105-
4. LambdaBuffers.Runtime.Plutarch is a module provided by the [lbr-plutarch](../runtimes/haskell/lbr-plutarch) runtime library.
102+
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.
103+
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.
104+
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.
105+
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.
106106

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

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

150-
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.
150+
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.
151151

152152
## Plutarch
153153

154154
### Type definition mapping
155155

156-
Plutarch backend supports all types from the [LambdaBuffers Plutus](../libs/lbf-plutus) schema library, as to enable full featured Plutus script development.
156+
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.
157157

158-
Additionally, it also supports some types from the [LambdaBuffers Prelude](../libs/lbf-prelude) schema library, namely `Bool`, `Integer`, `Maybe`, `Either` and `List`.
158+
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`.
159159

160160
```lbf
161161
module Foo
@@ -318,7 +318,7 @@ All generated types have a PShow instance derived using the internal Plutarch de
318318

319319
## Example
320320

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

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

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

341341
The salient bits we should focus on are:
342342

343-
1. The LambdaBuffers .lbf schema in [./api/Example.lbf](./plutarch/api/Example.lbf) that describes the API types used by our little program,
344-
2. The Haskell Plutarch program in [./app/Example.hs](./plutarch/app/Example.hs) that works with the API types.
343+
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,
344+
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.
345345

346346
To inspect the generated library:
347347

@@ -359,7 +359,7 @@ autogen/LambdaBuffers/Example/Plutarch.hs
359359
360360
However, it's not expected for users to need to do this. If you have any issue please reach out.
361361

362-
Inspecting the [Cabal file](./plutarch/plutarch-example.cabal) shows the standard runtime libraries we need:
362+
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:
363363

364364
```shell
365365
lambda-buffers/docs/plutarch ❯ cabal info .
@@ -388,4 +388,4 @@ lambda-buffers/docs/plutarch ❯ cabal run
388388
"Friends, peace and love!!!"
389389
```
390390

391-
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`).
391+
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`).

docs/plutarch/plutarch-example.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ common common-language
2020
ghc-options: -Werror
2121

2222
default-extensions:
23-
NoStarIsType
2423
BangPatterns
2524
BinaryLiterals
2625
ConstrainedClassMethods
@@ -57,6 +56,7 @@ common common-language
5756
MultiParamTypeClasses
5857
NamedFieldPuns
5958
NamedWildCards
59+
NoStarIsType
6060
NumericUnderscores
6161
OverloadedLabels
6262
OverloadedStrings

0 commit comments

Comments
 (0)