symbol-parser: Type level string parser combinators

[ data, deprecated, library, mit, types ] [ Propose Tags ]
Deprecated in favor of symparsec

Please see

[Skip to Readme]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.1.0, 0.2.0, 0.3.0
Change log
Dependencies base (>=4.16 && <5), defun-core (>=0.1 && <0.2) [details]
License MIT
Author Ben Orchard
Maintainer Ben Orchard <>
Revised Revision 1 made by raehik at 2024-04-19T03:16:28Z
Category Types, Data
Home page
Bug tracker
Source repo head: git clone
Uploaded by raehik at 2024-04-17T17:22:54Z
Distributions NixOS:0.3.0
Downloads 52 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for symbol-parser-0.1.0

[back to package description]


Type level string (Symbol) parser combinators with nice error messages.

This library is effectively made possible by UnconsSymbol :: Symbol -> Maybe (Char, Symbol) introduced in GHC 9.2. A big thank you to all GHC developers!!!


ghci> import Data.Type.Symbol.Parser
ghci> :k! RunParser (Drop 3 :*>: Isolate 2 NatDec :<*>: (Drop 3 :*>: NatHex)) "___10___FF"
= Right '( '(10, 255), "")


type Parser s r = Char -> s -> Result s r
data Result s r = Cont s | Done r | Err ErrorMessage

Symbols are parsed Char by Char. For each Char, the parser is called with the Char in question and the current parser state. Parsing continues based on the result.

We pass parsers around via defunctionalization symbols. The plumbing here is provided by Oleg's fantastic [defun-core][hackage-defun-core].

I try to keep the internals as simple as possible. Hopefully, this library looks like any other parser combinator, except reflected up to the type level.


Via GHC.Generics, we may inspect Haskell data types on the type level. Constructor names are Symbols. Ever reify these, then perform some sort of checking or parsing on the term level? Now you can do it on the type level instead. Catch bugs earlier, get faster runtime.

I want to help

I would gladly accept further combinators or other suggestions. Please add an issue or pull request, or contact me via email or whatever (I'm raehik everywhere).


Provided under the MIT license. See LICENSE for license text.