Skip to content
On this page

Primitives and composites

There are two types of parser and combinators: primitive and composite ones. Technically, you do not need to know any of that to use the library, but if you ever want or need to write a custom parser or combinator, knowing the difference may help to avoid some performance issues.



Marked in docs with this badge: primitive

These parsers and combinators are usually the very basic building blocks and written in plain and mostly imperative TypeScript without using other parsers/combinators to reduce performance overheads. After all, function calls have a price!

Examples: choice, many, sequence, string, oneOf, regexp, and others.



Marked in docs with this badge: composite

These parsers and combinators are built using other parsers/combinators. Some of them, of course, could be rewritten to be primitive, but sometimes it is too impractical or does not bring significant enough performance gains, and one of the goals is to keep the footprint of the library as small as possible.

Examples: chainl, sepBy, float, letters, and others.