package parsite

  1. Overview
  2. Docs
A micro library for simple parsing combinators

Install

dune-project
 Dependency

Authors

Maintainers

Sources

parsite-0.1.2.tbz
sha256=15f763e9d98014be41677913974ade7c1346bc5f8cae927b7fd24984c251879c
sha512=9fabb389cc6f68fa8b106a9939d41651824693192a1feb67cfda034e9bb18dd6c7702a43da10943ff462f762b5178349894291596fc1e1384c9b4e161de1551d

doc/parsite/Parsite/Types/index.html

Module Parsite.TypesSource

Parsite types, courtesy of faber-1

Sourcetype ('a, 'b) p_result =
  1. | Win of 'b * 'a
  2. | Lose of string

A p_result type is what a parser will return after running. It takes types 'a and 'b where 'a is the type of the input that is being parsed, and 'b is the type of the output of your parsing.

The p_result type is constructed with either a Win constructor that holds a ('b * 'a) tuple or a Lose constructor that holds an error message.

The input and output types are both variable types in case you want to make your own parser with custom types!

Sourcemodule PResultM : sig ... end

There's also the PResultM monad which has a return function that wrapps its input in a Win constructor, and the bind (>>=) operator which applies a function to a p_result value if that value is a Win value.

Sourcetype ('a, 'b) p_func = 'a -> ('a, 'b) p_result

The p_func type is the type signature for parser functions. Like p_result, it takes in types 'a and 'b where 'a is the type of the input and 'b is the type of the output.