Skip to content

A string parsing library heavily inspired by elm/parser.

License

Notifications You must be signed in to change notification settings

deviant-forks/gleam-nibble

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nibble

Package Version Hex Docs

A string parsing library heavily inspired by elm/parser.

Quick start

import gleam/function
import nibble.{ Parser }

type Point {
    Point(x: Int, y: Int)
}

pub fn main () {
    let parser = 
        nibble.succeed(function.curry2(Point))
            |> nibble.drop(nibble.grapheme("("))
            |> nibble.drop(nibble.spaces())
            |> nibble.keep(nibble.int())
            |> nibble.drop(nibble.spaces())
            |> nibble.drop(nibble.grapheme(","))
            |> nibble.drop(nibble.spaces())
            |> nibble.keep(nibble.int())
            |> nibble.drop(nibble.spaces())
            |> nibble.drop(nibble.grapheme(")"))

    assert Ok(point) = nibble.run("(1, 2)", parser)

    point.x //=> 1
    point.y //=> 2
}

Installation

If available on Hex this package can be added to your Gleam project:

gleam add nibble

and its documentation can be found at https://hexdocs.pm/nibble.

About

A string parsing library heavily inspired by elm/parser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Gleam 100.0%