commonmark-hs icon indicating copy to clipboard operation
commonmark-hs copied to clipboard

New system for source map

Open jgm opened this issue 4 years ago • 0 comments

The current system (defining a new typeclass instance for the constructors) doesn't give fine-grained enough information (e.g. it doesn't distinguish code span delimiters from the code). And it is awkwardly designed, so that for example it's easy to write instances that produce loops.

Better to put a field in state that keeps a source map, and maybe another field that controls whether to populate it (for efficiency this can be turned off). Then the individual constructors can be designed to insert whatever fine-grained mapping data would be useful.

Alternatively, instead of making these parsers work for any Monad, limit to the HasSourceMap typeclass and define dummy default instances for common monads.

jgm avatar Mar 11 '20 05:03 jgm