Symparsec: Type level string parser combinators, now with free runtime reifying

I made an update to symbol-parser that I think is worth sharing. Copied from reddit thread here.

I previously posted about Symparsec under a different name symbol-parser. Since then I’ve renamed it, rewritten it, fixed bugs, and filled out more basic parsers. Most usefully, I’ve written reified runtime versions of each parser. Now you can do

ghci> import Symparsec
ghci> type ParseSomeStuff = Skip 2 :*>: Literal " " :*>: Isolate 2 NatHex
ghci> :k! Run ParseSomeStuff "xx FFetc"
Run (...
= Right '(255, "etc")
ghci> import Singleraeh.Demote ( demote )
ghci> run' @ParseSomeStuff demote "xx FFetc"
Right (255,"etc")

Notably, these are guaranteed to have identical behaviour to their type-level counterparts, as they are internally defined using singletons.

I’m eager to write some usage examples since I’m conscious that mixing type and term level can be messy. Please let me know if you want a hand using Symparsec!

7 Likes