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 ?
As mentioned by @user2407038, the following should work:
customWriterCompilerWith customWriter ropt wopt = do
body <- getResourceBody
doc <- readPandocWith ropt body
withItemBody (unsafeCompiler . customWriter wopt) doc
To read more about <-
(which is syntactic sugar for >>=
), I can recommend http://learnyouahaskell.com (the monad chapter).