Skip to content

Commit

Permalink
Merge pull request #3 from lukewilliamboswell/more-docs
Browse files Browse the repository at this point in the history
update README
  • Loading branch information
lukewilliamboswell authored Dec 3, 2023
2 parents 8b71441 + 3784518 commit f0a40ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@

A simple [Parser Combinator](https://en.wikipedia.org/wiki/Parser_combinator) package for Roc.

```roc
color : Parser Utf8 [Red, Green, Blue]
color =
oneOf [
const Red |> skip (string "red"),
const Green |> skip (string "green"),
const Blue |> skip (string "blue"),
]
expect parseStr color "green" == Ok Green
```

## Documentation

See [lukewilliamboswell.github.io/roc-parser/](https://lukewilliamboswell.github.io/roc-parser/)

Locally generate docs using `roc docs package/main.roc`

## Contributing

If you see anything that could be improved please create an Issue or submit a PR.
Expand All @@ -14,10 +28,6 @@ If you see anything that could be improved please create an Issue or submit a PR

Run tests locally with `roc test package/main.roc`

## Generate Docs

Generate package documentation locally using `roc docs package/main.roc`

## Packaging

Bundle package into a URL for distribution using `roc build --bundle .tar.br package/main.roc`
12 changes: 6 additions & 6 deletions package/Core.roc
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ andThen = \firstParser, buildNextParser ->

## Try a list of parsers in turn, until one of them succeeds.
## ```
## color : Parser (List U8) [Red, Green, Blue]
## color =
## color : Parser Utf8 [Red, Green, Blue]
## color =
## oneOf [
## string "red" |> map \_ -> Red,
## string "green" |> map \_ -> Green,
## string "blue" |> map \_ -> Blue,
## const Red |> skip (string "red"),
## const Green |> skip (string "green"),
## const Blue |> skip (string "blue"),
## ]
##
##
## expect parseStr color "green" == Ok Green
## ```
oneOf : List (Parser input a) -> Parser input a
Expand Down

0 comments on commit f0a40ee

Please sign in to comment.