I taught ghci to compile my StackOverflow posts. Can I make it slicker?

后端 未结 1 1488
死守一世寂寞
死守一世寂寞 2020-12-13 09:33

Haskell Stack Overflow layout preprocessor

module StackOverflow where  -- yes, the source of this post compiles as is

Skip down to

相关标签:
1条回答
  • 2020-12-13 10:08

    I would try to make a standalone preprocessor that runs SO preprocessing code or the standard literary preprocessor, depending on file extension. Then just use :set -pgmL SO-preprocessor in ghci.conf.

    For the standard literary preprocessor, run the unlit program, or use Distribution.Simple.PreProcess.Unlit.

    This way, :load and filename completion just work normally.

    GHCI passes 4 arguments to the preprocessor, in order: -h, the label, the source file name, and the destination file name. The preprocessor should read the source and write to the destination. The label is used to output #line pragmas. You can ignore it if you don't alter the line count of the source (i.e. replace "comment" lines with -- comments or blank lines).

    0 讨论(0)
提交回复
热议问题