Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Hampus Weslien committed Jul 31, 2023
1 parent e2da3b6 commit a5b7e08
Show file tree
Hide file tree
Showing 226 changed files with 570 additions and 554 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ So the `point` function only gets the result of the two `float` parsers.

I recommend having one line per operator in your parser pipeline. If you need multiple lines for some reason, use a let or make a helper function.

If you want to have look at a larger example head over to the [Kombo-Json repository](https://github.com/honungsburk/kombo-json)
If you want to have look at a larger example head over to the [Kombo-Json repository](https://github.com/honungsburk/kombo-json), and if you still feel unsure you can clone the [Kombo Workshop repository](https://github.com/honungsburk/kombo-workshop) and
go through the exercises.

## Backtracking

Expand All @@ -88,13 +89,13 @@ So the defaults are nice, but sometimes the easiest way to write a parser is to

Most parsers tell you the row and column of the problem:

```txt
```text
Something went wrong at (4:17)
```

That may be true, but it is not how humans think. It is how text editors think! It would be better to say:

```txt
```text
I found a problem with this list:
[ 1, 23zm5, 3 ]
Expand All @@ -105,19 +106,10 @@ I wanted an integer, like 6 or 90219.

Notice that the error messages says `this list`. That is context! That is the language my brain speaks, not rows and columns.

Once you get comfortable with the `Simple` module, you can switch over to `Advanced` and use [`inContext`](https://example.com#inContext) to track exactly what your parser thinks it is doing at the moment. You can let the parser know “I am trying to parse a `"list"` right now” so if an error happens anywhere in that context, you get the hand annotation!
Once you get comfortable with the [`Simple`](https://frankhampusweslien.com/kombo/modules/Simple.html) module, you can switch over to [`Advanced`](https://frankhampusweslien.com/kombo/modules/Advanced.html) and use [`inContext`](https://frankhampusweslien.com/kombo/functions/Advanced.inContext.html) to track exactly what your parser thinks it is doing at the moment. You can let the parser know “I am trying to parse a `"list"` right now” so if an error happens anywhere in that context, you get the hand annotation!

This technique is used by the parser in the Elm compiler to give more helpful error messages.

## Links

- [Comparison with Prior Work](https://github.com/honungsburk/kombo/blob/master/comparison.md)
- [Parse, don't validate](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/)
- [Kombo docs](https://honungsburk.github.io/kombo)
- [github](https://github.com/honungsburk/kombo)
- [npm](https://github.com/honungsburk/kombo)
- [personal website](https://honungsburk.github.io/)

## FAQ

### Why did you name this library _Kombo_?
Expand All @@ -127,3 +119,17 @@ This is a parser _combinator_ library, and the Swedish word for _combo_ is , you
### Do you have any large examples on how to build a real parser using Kombo?

Checkout the [Kombo JSON Parser](https://github.com/honungsburk/kombo-json)

### I still don't know how to use it!

Don't fret! Clone the [Kombo Workshop repository](https://github.com/honungsburk/kombo-workshop) and
go through the exercises.

## Links

- [Comparison with Prior Work](https://github.com/honungsburk/kombo/blob/master/comparison.md)
- [Parse, don't validate](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/)
- [Kombo docs](https://honungsburk.github.io/kombo)
- [github](https://github.com/honungsburk/kombo)
- [npm](https://github.com/honungsburk/kombo)
- [personal website](https://honungsburk.github.io/)
4 changes: 2 additions & 2 deletions docs/functions/Advanced.Done-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>value: <span class="tsd-signature-type" data-tsd-kind="Type parameter">A</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../modules/Simple.html" class="tsd-signature-type" data-tsd-kind="Namespace">Simple</a><span class="tsd-signature-symbol">.</span><a href="../types/Simple.Done.html" class="tsd-signature-type" data-tsd-kind="Type alias">Done</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">A</span><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/b3988bc/src/Advanced.ts#L505">Advanced.ts:505</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/e2da3b6/src/Advanced.ts#L505">Advanced.ts:505</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a></nav>
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a><a href="https://github.com/honungsburk/kombo-json" target="_blank">kombo-json</a><a href="https://github.com/honungsburk/kombo-workshop" target="_blank">kombo-workshop</a></nav>
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/Advanced.Loop-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>state: <span class="tsd-signature-type" data-tsd-kind="Type parameter">STATE</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../modules/Simple.html" class="tsd-signature-type" data-tsd-kind="Namespace">Simple</a><span class="tsd-signature-symbol">.</span><a href="../types/Simple.Loop.html" class="tsd-signature-type" data-tsd-kind="Type alias">Loop</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">STATE</span><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/b3988bc/src/Advanced.ts#L478">Advanced.ts:478</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/e2da3b6/src/Advanced.ts#L478">Advanced.ts:478</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a></nav>
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a><a href="https://github.com/honungsburk/kombo-json" target="_blank">kombo-json</a><a href="https://github.com/honungsburk/kombo-workshop" target="_blank">kombo-workshop</a></nav>
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/Advanced.Token-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ <h5>value: <span class="tsd-signature-type">string</span></h5></li>
<h5>problem: <span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../modules/Advanced.html" class="tsd-signature-type" data-tsd-kind="Namespace">Advanced</a><span class="tsd-signature-symbol">.</span><a href="../types/Advanced.Token.html" class="tsd-signature-type" data-tsd-kind="Type alias">Token</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/b3988bc/src/Advanced.ts#L650">Advanced.ts:650</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/e2da3b6/src/Advanced.ts#L650">Advanced.ts:650</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a></nav>
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a><a href="https://github.com/honungsburk/kombo-json" target="_blank">kombo-json</a><a href="https://github.com/honungsburk/kombo-workshop" target="_blank">kombo-workshop</a></nav>
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/Advanced.andThen.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>p: <a href="../modules/Parser.html" class="tsd-signature-type" data-tsd-kind="Namespace">Parser</a><span class="tsd-signature-symbol">.</span><a href="../interfaces/Parser.Parser.html" class="tsd-signature-type" data-tsd-kind="Interface">Parser</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">A</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX2</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM2</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../modules/Parser.html" class="tsd-signature-type" data-tsd-kind="Namespace">Parser</a><span class="tsd-signature-symbol">.</span><a href="../interfaces/Parser.Parser.html" class="tsd-signature-type" data-tsd-kind="Interface">Parser</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">B</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX2</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM2</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></li></ul><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/b3988bc/src/Advanced.ts#L290">Advanced.ts:290</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/e2da3b6/src/Advanced.ts#L290">Advanced.ts:290</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a></nav>
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a><a href="https://github.com/honungsburk/kombo-json" target="_blank">kombo-json</a><a href="https://github.com/honungsburk/kombo-workshop" target="_blank">kombo-workshop</a></nav>
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/Advanced.apply.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>parseArg: <a href="../modules/Parser.html" class="tsd-signature-type" data-tsd-kind="Namespace">Parser</a><span class="tsd-signature-symbol">.</span><a href="../interfaces/Parser.Parser.html" class="tsd-signature-type" data-tsd-kind="Interface">Parser</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">A</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX2</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM2</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../modules/Parser.html" class="tsd-signature-type" data-tsd-kind="Namespace">Parser</a><span class="tsd-signature-symbol">.</span><a href="../interfaces/Parser.Parser.html" class="tsd-signature-type" data-tsd-kind="Interface">Parser</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">B</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX2</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM2</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></li></ul><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/b3988bc/src/Advanced.ts#L238">Advanced.ts:238</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/e2da3b6/src/Advanced.ts#L238">Advanced.ts:238</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a></nav>
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a><a href="https://github.com/honungsburk/kombo-json" target="_blank">kombo-json</a><a href="https://github.com/honungsburk/kombo-workshop" target="_blank">kombo-workshop</a></nav>
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/Advanced.backtrackable.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>parser: <a href="../modules/Parser.html" class="tsd-signature-type" data-tsd-kind="Namespace">Parser</a><span class="tsd-signature-symbol">.</span><a href="../interfaces/Parser.Parser.html" class="tsd-signature-type" data-tsd-kind="Interface">Parser</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">A</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../modules/Parser.html" class="tsd-signature-type" data-tsd-kind="Namespace">Parser</a><span class="tsd-signature-symbol">.</span><a href="../interfaces/Parser.Parser.html" class="tsd-signature-type" data-tsd-kind="Interface">Parser</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">A</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">CTX</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/b3988bc/src/Advanced.ts#L585">Advanced.ts:585</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/e2da3b6/src/Advanced.ts#L585">Advanced.ts:585</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a></nav>
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a><a href="https://github.com/honungsburk/kombo-json" target="_blank">kombo-json</a><a href="https://github.com/honungsburk/kombo-workshop" target="_blank">kombo-workshop</a></nav>
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/Advanced.chompIf.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>expecting: <span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../modules/Parser.html" class="tsd-signature-type" data-tsd-kind="Namespace">Parser</a><span class="tsd-signature-symbol">.</span><a href="../interfaces/Parser.Parser.html" class="tsd-signature-type" data-tsd-kind="Interface">Parser</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">PROBLEM</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></li></ul><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/b3988bc/src/Advanced.ts#L1032">Advanced.ts:1032</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/honungsburk/kombo/blob/e2da3b6/src/Advanced.ts#L1032">Advanced.ts:1032</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a></nav>
<nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/honungsburk/kombo" target="_blank">github</a><a href="https://github.com/honungsburk/kombo-json" target="_blank">kombo-json</a><a href="https://github.com/honungsburk/kombo-workshop" target="_blank">kombo-workshop</a></nav>
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
Expand Down
Loading

0 comments on commit a5b7e08

Please sign in to comment.