1

I'm trying to write a special Hakyll compiler to use a lua script to build my website. I found this function which seams to make what I want :

customWriterCompilerWith :: (WriterOptions -> Pandoc -> IO String)
                         -> ReaderOptions -> WriterOptions
                         -> Compiler (Item String)
customWriterCompilerWith customWriter ropt wopt = do
    body <- getResourceBody
    withItemBody (unsafeCompiler . customWriter wopt) $ readPandocWith ropt body

However, when I try to compile this function, I get this error :

• Couldn't match expected type ‘Item Pandoc’
              with actual type ‘Compiler (Item Pandoc)’
• In the second argument of ‘($)’, namely
    ‘readPandocWith ropt body’

After searching in the Hakyll documentation, there is a difference between the type of readPandocWith in versions 4.6.8.0 and 4.9.8.0 (my version) :

readPandocWith:: ReaderOptions-> Item String-> Item Pandoc -- 4.6.8.0

readPandocWith:: ReaderOptions-> Item String-> Compiler (Item Pandoc) -- 4.9.8.0

I didn't find in the Hakyll documentation a function (whose type should be Compiler (Item Pandoc)-> Item Pandoc) which could help me.

Do you know how to solve this problem ?

Do you know another way to make a custom Hakyll compiler with a LUA script ?

4

1 回答 1

0

正如@user2407038 所提到的,以下应该有效:

customWriterCompilerWith customWriter ropt wopt = do
    body <- getResourceBody
    doc  <- readPandocWith ropt body
    withItemBody (unsafeCompiler . customWriter wopt) doc

要了解更多信息<-(这是 的语法糖>>=),我可以推荐http://learnyouahaskell.com(monad 章节)。

于 2017-07-08T14:41:37.797 回答