You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rough idea, extracted from a recent discussion. Let us have fixpoint combinator.
let rec fix pf = pf (fun _ -> fix pf)
Then each (possibly recursive) type can be also compiled to a JSON parser of its values in a parser-combinator style. For example:
type Tree = Leaf | Node of Tree * Uint32 * Tree
would be compiled to something like:
let node_parser self = seq parse_string("Node") @@ seq (self ()) @@ seq parse_uint32 (self())
let leaf_parser = parse_string "Leaf"
let tree_parser = fix (fun self -> alt leaf_parser (node_parser self))
Parsers for polymorphic types would need to take lists of parsers for data types, corresponding to their type parameters, which they can use in their implementation.
let pair_parser params =
let a_parser = get params 1 in
let b_parser = get params 2 in
seq parse_string("Pair") @@ seq a_parser b_parser
The text was updated successfully, but these errors were encountered:
The rough idea, extracted from a recent discussion. Let us have fixpoint combinator.
Then each (possibly recursive) type can be also compiled to a JSON parser of its values in a parser-combinator style. For example:
would be compiled to something like:
Parsers for polymorphic types would need to take lists of parsers for data types, corresponding to their type parameters, which they can use in their implementation.
The text was updated successfully, but these errors were encountered: