open icon indicating copy to clipboard operation
open copied to clipboard

Source mapping for Inliterate

Open NickSeagull opened this issue 7 years ago • 6 comments

I was thinking that maybe it would be useful to have source maps generated by inliterate so in case of error, one could parse it, look into the source map file and replace it so the user could see where the real errors are instead of random numbering 😃 .

Does this make sense for you? I'm thinking about implementing error highlighting in Haskell.do, but without this it would be very difficult.

I would be willing to help with this 😁

NickSeagull avatar Aug 02 '17 14:08 NickSeagull

Is this possible? Can you link to GHC doc page if so?

glutamate avatar Aug 02 '17 14:08 glutamate

I'm not really sure if this is possible, it was just an idea that maybe could make sense, I was thinking about hand parsing both files, the source and the generated, and try to find the line with an error from the generated one in the source. Might not cover all the use cases, but I think it could be a start

NickSeagull avatar Aug 02 '17 15:08 NickSeagull

This should be possible using GHC's LINE and COLUMN pragmas: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#line-pragma

vasiliyl avatar Sep 25 '17 08:09 vasiliyl

@vasiliyl :arrow_up: this looks quite promising. @glutamate would you like to have me submit a pull request for this? If so, could you please point me where the code generation is made so I can add these pragmas?

NickSeagull avatar Sep 25 '17 09:09 NickSeagull

@vasiliyl @NickSeagull i agree this is the way to go. Right now everything is parsed by cheapskate with its markdown and i dont think its Doc type preserves the source line location? but cheapskate could be replaced, there are many haskell markdown parsers. I would be reluctant to change to a GPL licensed parser though.

glutamate avatar Sep 25 '17 09:09 glutamate

@glutamate agree 100% with the GPL decision

NickSeagull avatar Sep 25 '17 12:09 NickSeagull