elm-community / parser-combinators

A parser combinator library for Elm.

Home Page:http://package.elm-lang.org/packages/elm-community/parser-combinators/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generalizing over input type

mzero opened this issue · comments

Any interest in generalizing this over input stream time?

I'm working on parsing MIDI messages (via JS WebMIDI API) - and recently had to essentially duplicate about half of this module so it could parse over byte streams, rather than Strings.

Many of the functions are agnostic about input stream type, and generalizing these is trivial. The rest are String specific, and might be better in a string specific module. Optionally there could be a module that makes the parsing types specific to String, and then adds the string specific functions.

I haven't heard a prior proposal for this, but it may be a good idea.
What would you then propose that the input becomes? A Listor Array of Char? Changing the parser type to take another type-constructor argument would do the trick I imagine.

By the way. Have you looked into elm-comidi? Maybe this already does what you try to do.

I'm working on elm-comidi right now and debugging would be much nicer if things were in terms of a list of chars or ints (since we don't have proper bytes).

Edit: Actually, I think my debugging issues are more with how Elm is rending binary strings than the fact that they're strings.