@@ -63,10 +63,16 @@ To generate Purescript .purs files from .proto files, run:
63[nix-shell]$
63[nix-shell]$
66−If you don't want to use Nix, then install the Purescript toolchain and *protoc*.
66+If you don't want to use Nix, then install the Purescript toolchain and `protoc`,
67+and add the executable script
68+[`bin/protoc-gen-purescript`](bin/protoc-gen-purescript)
68## Writing programs with the generated code
71## Writing programs with the generated code
73+The code generator will use the `package` import statement in the `.proto` file
74+and the base `.proto` file name as the Purescript module name for that file.
70A message in a `shapes.proto` file declared as
76A message in a `shapes.proto` file declared as
@@ -78,7 +84,8 @@ message Rectangle {
87+will export these four names from module `Interproc.Shapes` in a
81−will export these four names in a generated `shapes.Interproc.purs` file.
88+generated `shapes.Interproc.purs` file.
831. A message data type
901. A message data type
@@ -86,6 +93,9 @@ will export these four names in a generated `shapes.Interproc.purs` file.
86 newtype Rectangle = Rectangle { width :: Maybe Number, height :: Maybe Number }
93 newtype Rectangle = Rectangle { width :: Maybe Number, height :: Maybe Number }
96+ The message data type will also include an `__unknown_fields` field which
97+ is required for conformance.
892. A message maker which constructs a message from a `Record`
992. A message maker which constructs a message from a `Record`
90 with some message fields
100 with some message fields
@@ -93,7 +103,11 @@ will export these four names in a generated `shapes.Interproc.purs` file.
93 mkRectangle :: forall r. Record r -> Rectangle
103 mkRectangle :: forall r. Record r -> Rectangle
106+ All message fields are optional, and can be elided when making a message.
107+ There are some extra type constraints, not shown here, which will cause a
108+ compiler error if we try to add a field which is not in the message data type.
96− All message fields are optional, and can be omitted from the `Record`. If we want the compiler to check that we've explicitly supplied all the fields,
110+ If we want the compiler to check that we've explicitly supplied all the fields,
97 then we can use the ordinary message data type constructor.
111 then we can use the ordinary message data type constructor.
993. A message encoder which works with
1133. A message encoder which works with
@@ -235,10 +249,7 @@ The path to the protobuf definition which failed to parse will be included
235in the `ParseError String` and delimited by `'/'`, something
249in the `ParseError String` and delimited by `'/'`, something
236like `"Message1 / string_field_1 / Invalid UTF8 encoding."`.
250like `"Message1 / string_field_1 / Invalid UTF8 encoding."`.
238−### Imports
252+### Protobuf Imports
240−The code generator will use the `package` statement in the `.proto` file
241−and the base file name as the Purescript module name for that file.
243The Protobuf
254The Protobuf
244[`import`](https://developers.google.com/protocol-buffers/docs/proto3#importing_definitions)
255[`import`](https://developers.google.com/protocol-buffers/docs/proto3#importing_definitions)
@@ -251,10 +262,12 @@ statement in the imported file.
252For that reason, we can only use top-level
263For that reason, we can only use top-level
253(not [nested](https://developers.google.com/protocol-buffers/docs/proto3#nested))
264(not [nested](https://developers.google.com/protocol-buffers/docs/proto3#nested))
254−`message` and `enum` types from an `import`.
265+`message` and `enum` types from a Protobuf `import`.
267+### PureScript Imports
256The generated Purescript code will usually have module imports which cause
269The generated Purescript code will usually have module imports which cause
257−the `purs` compiler to emit warnings. Sorry.
270+the `purs` compiler to emit warnings. We beg your pardon.
259## Nix derivation
272## Nix derivation