Library
Module
Module type
Parameter
Class
Class type
Parsite types, courtesy of faber-1
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!
module 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.
type ('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.