effect-grammar 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +23 -14
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,22 +2,31 @@
2
2
 
3
3
  Invertible grammar combinators and parser-printers for Effect.
4
4
 
5
- Schema models your structured data. `effect-grammar` models the text formats inside your strings: connection strings, duration strings (`1h30m`), cron expressions, search queries, or DSLs.
5
+ Schema models your structured data. `effect-grammar` models the text formats
6
+ inside your strings: connection strings, duration strings (`1h30m`), cron
7
+ expressions, search queries, or DSLs.
6
8
 
7
9
  You write the grammar definition once. You get four outputs:
8
10
 
9
- - **A Parser**: Reads text and outputs structured data with line and column error messages.
11
+ - **A Parser**: Reads text and outputs structured data with line and column
12
+ error messages.
10
13
  - **A Printer**: Converts structured data back to canonical text.
11
- - **A `Schema.Codec<A, string>`**: Integrates directly with Effect Schema (`decode` parses, `encode` prints, and Schema refinements compose).
12
- - **A Text Renderer**: Formats the grammar as readable text for documentation and schema descriptions.
14
+ - **A `Schema.Codec<A, string>`**: Integrates directly with Effect Schema
15
+ (`decode` parses, `encode` prints, and Schema refinements compose).
16
+ - **A Text Renderer**: Formats the grammar as readable text for documentation
17
+ and schema descriptions.
13
18
 
14
19
  ## Why effect-grammar?
15
20
 
16
- - **`Schema.transformOrFail`**: Requires you to write and maintain both `decode` and `encode` functions manually.
17
- - **`Schema.TemplateLiteralParser`**: Supports only flat `${a}-${b}` string patterns.
18
- - **`effect-grammar`**: Automatically derives the parser and printer for formats with optional parts, repetition, alternation, and recursion.
21
+ - **`Schema.transformOrFail`**: Requires you to write and maintain both `decode`
22
+ and `encode` functions manually.
23
+ - **`Schema.TemplateLiteralParser`**: Supports only flat `${a}-${b}` string
24
+ patterns.
25
+ - **`effect-grammar`**: Automatically derives the parser and printer for formats
26
+ with optional parts, repetition, alternation, and recursion.
19
27
 
20
- This is for format strings, not documents. The parser backtracks with no memoization and no left recursion. Printing is canonical, not pretty.
28
+ This is for format strings, not documents. The parser backtracks with no
29
+ memoization and no left recursion. Printing is canonical, not pretty.
21
30
 
22
31
  ## Install
23
32
 
@@ -57,10 +66,10 @@ A silent grammar (`literal`, `symbol`, `whitespace`, anything under `skip`)
57
66
  carries no value and can be `yield*`-ed bare. A value grammar goes through
58
67
  `field(name, g)`.
59
68
 
60
- `print` replays the generator. It reads each field from `value[name]` and
61
- passes that back as the `yield*` result. An `if` on a parsed value takes the
62
- same path both ways. The generator's return must hold every field under its
63
- name, and the types enforce it. Return nothing and you get the object of fields.
69
+ `print` replays the generator. It reads each field from `value[name]` and passes
70
+ that back as the `yield*` result. An `if` on a parsed value takes the same path
71
+ both ways. The generator's return must hold every field under its name, and the
72
+ types enforce it. Return nothing and you get the object of fields.
64
73
 
65
74
  `render` cannot read a generator. It runs the generator once with no values and
66
75
  shows the parts it yields. The rendering is exact when the generator is
@@ -105,8 +114,8 @@ Schema.encodeSync(Endpoint)({ host: "effect.website", port: 443 })
105
114
  ## Values and alternatives
106
115
 
107
116
  `transform` maps a value both ways. `decodeTo` takes a Schema that types
108
- `decode` and `encode` and checks the value on parse and on print. A `choice`
109
- of Schema-typed branches picks the matching Schema when printing.
117
+ `decode` and `encode` and checks the value on parse and on print. A `choice` of
118
+ Schema-typed branches picks the matching Schema when printing.
110
119
 
111
120
  ```ts
112
121
  const Num = Schema.Struct({ kind: Schema.Literal("num"), value: Schema.Finite })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "effect-grammar",
3
- "version": "0.1.0",
4
- "description": "Effect Schema, but for text formats: one grammar yields a parser, printer, rendered form, and Schema",
3
+ "version": "0.2.0",
4
+ "description": "Invertible grammar combinators and parser-printers for Effect.",
5
5
  "keywords": [
6
6
  "bidirectional",
7
7
  "effect",