1

I'm playing around with Hakyll and try to understand why it doesn't compile whet I use let statement in the following code snippet:

main :: IO ()
main = hakyll $ do
   -- some other matches

    match "index.html" $ do
      route idRoute
      compile $ do
        posts <- recentFirst =<< loadAll "index.html"
        let indexCtx =
              listField "posts" postCtx (return posts) <>
              constField "title" "Home"                <>
              defaultContext
        getResourceBody
          >>= applyAsTemplate defaultContext
          >>= loadAndApplyTemplate "templates/default.html" defaultContext
          >>= relativizeUrls

What do I try to do here is just to compile simple index.html template. And thing that seems strange to me is that it doesn't compile when I drop let statement. GHCi then starts to complain that:

    • No instance for (base-4.12.0.0:Data.Typeable.Internal.Typeable
                         a0)
        arising from a use of ‘loadAll’
    • In the second argument of ‘(=<<)’, namely ‘loadAll "index.html"’
      In a stmt of a 'do' block:
        posts <- recentFirst =<< loadAll "index.html"
      In the second argument of ‘($)’, namely
        ‘do posts <- recentFirst =<< loadAll "index.html"
            getResourceBody >>= applyAsTemplate defaultContext
              >>= loadAndApplyTemplate "templates/default.html" defaultContext
              >>= relativizeUrls’

As far as I know, let statement shouldn't infer to behavior in any ways since indexCtx is not even used elsewhere.

aryndin
  • 591
  • 5
  • 18

0 Answers0