我想寫一個特殊的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