この Hakyll blogを構築しようとしています。をコンパイルしようとするsite.hs
と、サイト構築プログラム...
root@AR:/usr/local# git clone https://github.com/relrod/blog elrod.me
root@AR:/usr/local# cd elrod.me
root@AR:/usr/local/elrod.me# ghc --make site.hs
...次のタイプのエラーが発生します。
[1 of 1] Compiling Main ( site.hs, site.o ) site.hs:28:70: error:
Couldn't match type ‘unordered-containers-0.2.7.2:Data.HashMap.Base.HashMap Data.Text.Internal.Text aeson-1.1.0.0:Data.Aeson.Types.Internal.Value’ with ‘M.Map [Char] a1’
Expected type: M.Map [Char] a1
Actual type: Metadata
In the third argument of ‘M.findWithDefault’, namely ‘metadata’
In the expression: M.findWithDefault "No title" "title" metadata
In an equation for ‘title’: title = M.findWithDefault "No title" "title" metadata
Relevant bindings include title :: a1 (bound at site.hs:28:25)
どうすれば修正できますか?の関連部分は次のsite.hs
とおりです。
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Map as M
import Data.Monoid ((<>))
import Hakyll
import Text.Pandoc.Options (readerSmart)
main :: IO ()
main = hakyll $ do
-- etc.
match "posts/*" $ do
route $ setExtension "html"
compile $ do
let safetitle = field "safetitle" $ \item -> do
metadata <- getMetadata (itemIdentifier item)
let title = M.findWithDefault "No title" "title" metadata
return $ concatMap (\x -> if x == '\'' then "\\'" else [x]) title
pandocCompilerWith defaultHakyllReaderOptions {readerSmart = False} defaultHakyllWriterOptions
>>= saveSnapshot "content"
>>= loadAndApplyTemplate "templates/post.html" (postCtx tags <> safetitle)
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
-- etc.