我想写一个特殊的Hakyll编译器来使用lua脚本来构建我的网站。我发现这个功能,接缝,使我想:Hakyll的自定义pandoc作者
customWriterCompilerWith :: (WriterOptions -> Pandoc -> IO String)
-> ReaderOptions -> WriterOptions
-> Compiler (Item String)
customWriterCompilerWith customWriter ropt wopt = do
body <- getResourceBody
withItemBody (unsafeCompiler . customWriter wopt) $ readPandocWith ropt body
然而,当我尝试编译这个功能,我得到这个错误:
• Couldn't match expected type ‘Item Pandoc’
with actual type ‘Compiler (Item Pandoc)’
• In the second argument of ‘($)’, namely
‘readPandocWith ropt body’
的Hakyll文档中搜索后,有的readPandocWith
类型之间的版本4.6.8.0
和4.9.8.0
(我的版本)的差异:
readPandocWith:: ReaderOptions-> Item String-> Item Pandoc -- 4.6.8.0
readPandocWith:: ReaderOptions-> Item String-> Compiler (Item Pandoc) -- 4.9.8.0
我没有在找Hakyll记录一个函数(其类型应该是Compiler (Item Pandoc)-> Item Pandoc
),它可以帮助我。
你知道如何解决这个问题吗?
您是否知道使用LUA脚本创建自定义Hakyll编译器的另一种方法?
没有这样的功能(它不能存在);所以它不是你想要的功能。你想要的实际功能是'>> = ::编译器a - >(a - >编译器b) - >编译器b'。或者,由于您已经在使用'do'符号,'do {body < - ..; doc < - readPandocWith ropt body; withItemBody(..)doc}'。除此之外:我建议熟悉几乎每个成熟的Haskell库所使用的更基本的抽象模式;这肯定会帮助你浏览Haskell生态系统。 – user2407038
@ user2407038做出这个答案。 – arrowd