Discussion:
[hakyll] Transition to version 4, everything "not in scope"
d***@gmail.com
2016-03-29 18:37:39 UTC
Permalink
I don't understand why the drastic changes, but now my stuff doesn't
compile after stupidly updating cabal, I now have the newest version of
Hakyll, built a quick site to make sure everything works but my old stuff
isn't running.









[1 of 1] Compiling Main ( bin/site.hs, bin/site.o )



bin/site.hs:31:12: Not in scope: ‘predicate’



bin/site.hs:58:12: Not in scope: ‘predicate’



bin/site.hs:66:27:

Not in scope: ‘constA’

Perhaps you meant ‘const’ (imported from Prelude)



bin/site.hs:67:18: Not in scope: ‘setField’



bin/site.hs:68:13: Not in scope: ‘requireAllA’



bin/site.hs:69:13: Not in scope: ‘requireAllA’



bin/site.hs:74:36:

Not in scope: ‘constA’

Perhaps you meant ‘const’ (imported from Prelude)



bin/site.hs:75:18: Not in scope: ‘setField’



bin/site.hs:76:13: Not in scope: ‘requireAllA’



bin/site.hs:81:38:

Not in scope: ‘constA’

Perhaps you meant ‘const’ (imported from Prelude)



bin/site.hs:82:18: Not in scope: ‘setField’



bin/site.hs:83:13: Not in scope: ‘requireAllA’



bin/site.hs:91:9: Not in scope: ‘requireAll_’



bin/site.hs:108:18:

Not in scope: type constructor or class ‘Resource’



bin/site.hs:115:30:

Not in scope: type constructor or class ‘Resource’



bin/site.hs:115:40: Not in scope: type constructor or class ‘Page’



bin/site.hs:117:29:

Not in scope: ‘readPage’

Perhaps you meant ‘readParen’ (imported from Prelude)



bin/site.hs:118:25: Not in scope: ‘addDefaultFields’



bin/site.hs:121:25: Not in scope: ‘pageRenderPandoc’



bin/site.hs:124:30:

Not in scope: type constructor or class ‘Resource’



bin/site.hs:124:40: Not in scope: type constructor or class ‘Page’



bin/site.hs:127:29:

Not in scope: ‘readPage’

Perhaps you meant ‘readParen’ (imported from Prelude)



bin/site.hs:128:25: Not in scope: ‘addDefaultFields’



bin/site.hs:131:25: Not in scope: ‘pageRenderPandoc’



bin/site.hs:155:14: Not in scope: type constructor or class ‘Page’



bin/site.hs:155:26: Not in scope: type constructor or class ‘Page’



bin/site.hs:156:32: Not in scope: ‘sortByBaseName’



bin/site.hs:159:18: Not in scope: ‘changeField’



bin/site.hs:162:14:

Not in scope: ‘renderField’

Perhaps you meant ‘teaserField’ (imported from Hakyll)



bin/site.hs:164:23: Not in scope: type constructor or class ‘Page’



bin/site.hs:164:37: Not in scope: type constructor or class ‘Page’



bin/site.hs:164:52: Not in scope: type constructor or class ‘Page’



bin/site.hs:167:26: Not in scope: type constructor or class ‘Page’



bin/site.hs:167:40: Not in scope: type constructor or class ‘Page’



bin/site.hs:167:55: Not in scope: type constructor or class ‘Page’



bin/site.hs:170:48: Not in scope: type constructor or class ‘Page’



bin/site.hs:170:62: Not in scope: type constructor or class ‘Page’



bin/site.hs:170:77: Not in scope: type constructor or class ‘Page’



bin/site.hs:171:28: Not in scope: ‘setFieldA’



bin/site.hs:172:20: Not in scope: ‘sortByBaseName’



bin/site.hs:174:13: Not in scope: ‘require’



bin/site.hs:176:17: Not in scope: ‘pageBody’

Can someone help me get this to work? I'm not really a haskell guy, total
newb.

Here is my site.hs:

{-# LANGUAGE OverloadedStrings, Arrows #-}
module Main where

import Prelude hiding (id)
import Control.Category (id)
import Control.Arrow ((>>>), (>>^), (***), arr)
import Control.Monad (forM_)
import Data.Monoid (mempty, mconcat)
import System.FilePath
import Hakyll

main :: IO ()
main = hakyll $ do

-----------------------------------------------------------------------
-- compile templates
-----------------------------------------------------------------------

match "templates/*" $ compile templateCompiler

-----------------------------------------------------------------------
-- copy resources files & process css as necessary
-----------------------------------------------------------------------
match "resources/css/**" $ do
route $ setRoot `composeRoutes` setExtension "css"
compile sass
-- compile $ byExtension (error "not a valid css file")
-- [ (".css", sass)
-- , (".scss", sass) ]

match (predicate (\i -> matches "resources/**" i && not (matches
"resources/css/**" i))) $ do
route setRoot
compile copyFileCompiler

-- create site pages
-----------------------------------------------------------------------

forM_ indexPages $ \p -> match p $ do
route $ setRoot `composeRoutes` toIndex
compile $ unGitHubCompiler
= loadAndApplyTemplate "templates/page.html"
= loadAndApplyTemplate "templates/default.html"
forM_ markdownPages $ \p -> match p $ do
route $ setRoot `composeRoutes` cleanURL
compile $ unGitHubCompiler
= loadAndApplyTemplate "templates/page.html"
= loadAndApplyTemplate "templates/default.html"
match "p*/**/index.html" $ do
route setRoot
compile defaultCompiler

match "p*/***.html" $ do
route $ setRoot `composeRoutes` cleanURL
compile defaultCompiler

match (predicate (\i -> matches "p*/**" i && not (matches "*.m*d" i)))
$ do
route $ setRoot `composeRoutes` idRoute
compile copyFileCompiler

-- special root pages
-----------------------------------------------------------------------

match "index.html" $ route idRoute
create "index.html" $ constA mempty
= arr (setField "pagetitle" "Franklin De Los Santos")
= requireAllA "posts/***.md" (id *** arr newest10 >>= postList)
= requireAllA "projects/*/*.md" projectList
= loadAndApplyTemplate "templates/home.html"
= loadAndApplyTemplate "templates/default.html"
match "./posts/index.html" $ route idRoute
create "./posts/index.html" $ constA mempty
= arr (setField "pagetitle" "Posts - Franklin De Los Santos")
= requireAllA "posts/***.md" postList
= loadAndApplyTemplate "templates/posts.html"
= loadAndApplyTemplate "templates/default.html"
match "./projects/index.html" $ route idRoute
create "./projects/index.html" $ constA mempty
= arr (setField "pagetitle" "Projects - Franklin De Los Santos")
= requireAllA "projects/*/*.md" projectList
= loadAndApplyTemplate "templates/projects.html"
= loadAndApplyTemplate "templates/default.html"
-- render rss feed
-----------------------------------------------------------------------
match "atom.xml" $ route idRoute
create "atom.xml" $
requireAll_ "projects/*/*.md" >>= renderAtom feedConfiguration

where
indexPages = [ "p*/**README.*"
, "p*/**index.*" ]
markdownPages = [ "p*/***.md"
, "p*/***.mkd"
, "p*/***.mkdn"
, "p*/***.mdown"
, "p*/***.markdown"
, "p*/***.pandoc"
, "p*/***.pdc"
, "p*/***.lhs" ]
-----------------------------------------------------------------------
-- custom compilers
-----------------------------------------------------------------------

sass :: Compiler Resource String
sass = getResourceString >>= unixFilter "sass" ["-s", "--scss"]
= arr compressCss
unGitHub :: Compiler String String
unGitHub = unixFilter "sed"
["s+https://github.com/[^/]*/\\([^:/]*\\)/raw/master+/\\1+g"]

defaultCompiler :: Compiler Resource (Page String)
defaultCompiler = getResourceString
= arr readPage
= addDefaultFields
= arr applyAsTemplate
= arr buildTitle
= pageRenderPandoc
= loadAndApplyTemplate "templates/default.html"
unGitHubCompiler :: Compiler Resource (Page String)
unGitHubCompiler = getResourceString
= unGitHub
= arr readPage
= addDefaultFields
= arr applyAsTemplate
= arr buildTitle
= pageRenderPandoc
-- custom routes
-----------------------------------------------------------------------
setRoot :: Routes
setRoot = customRoute stripTopDir

stripTopDir :: Identifier -> FilePath
stripTopDir = joinPath . tail . splitPath . toFilePath

cleanURL :: Routes
cleanURL = customRoute fileToDirectory

fileToDirectory :: Identifier -> FilePath
fileToDirectory = (flip combine) "index.html" . dropExtension . toFilePath

toIndex :: Routes
toIndex = customRoute fileToIndex

fileToIndex :: Identifier -> FilePath
fileToIndex = (flip combine) "index.html" . dropFileName . toFilePath

-- misc functions
-----------------------------------------------------------------------
newest10 :: [Page a] -> [Page a]
newest10 = take 10 . reverse . sortByBaseName

stripIndexLink :: Item a -> Item a
stripIndexLink = changeField "url" dropFileName

buildTitle :: Item a -> Item a
buildTitle = renderField "title" "pagetitle" (++ " - Franklin De Los
Santos")

postList :: Compiler (Page String, [Page String]) (Page String)
postList = buildList "postlist" "templates/item.html"

projectList :: Compiler (Page String, [Page String]) (Page String)
projectList = buildList "projectlist" "templates/item.html"

buildList :: String -> Identifier -> Compiler (Page String, [Page String])
(Page String)
buildList field template = setFieldA field $
arr (reverse . sortByBaseName)
= arr (map stripIndexLink)
= require template (\p t -> map (applyTemplate t) p)
= arr mconcat
= arr pageBody
-- misc functions
-----------------------------------------------------------------------
feedConfiguration :: FeedConfiguration
feedConfiguration = FeedConfiguration
{ feedTitle = "fadelosa.com"
, feedDescription = "Projects & Posts from Franklin De Los Santos"
, feedAuthorName = "Franklin De Los Santos"
, feedRoot = "http://fadelosa.com"
}


I made some small changes, but I've been at this all night.
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jasper Van der Jeugt
2016-03-30 13:36:33 UTC
Permalink
Hello,

Hakyll 4 was released a bit over 3 years ago, which is a pretty long
time in the open source world for a small/medium-scale project like
Hakyll. There are some general tips here:

https://jaspervdj.be/hakyll/tutorials/hakyll-3-to-hakyll4-migration-guide.html

If you read that and a couple of the basic Hakyll tutorials, porting it
shouldn't take that long (it's only 200 lines). Furthermore, much of the
code should be simplified. However, I don't think you can expect anoyone
to rewrite the thing for free.

If you have more specific questions, I'd be happy to answer them.

Peace,
Jasper
Post by d***@gmail.com
I don't understand why the drastic changes, but now my stuff doesn't
compile after stupidly updating cabal, I now have the newest version of
Hakyll, built a quick site to make sure everything works but my old stuff
isn't running.
[1 of 1] Compiling Main ( bin/site.hs, bin/site.o )
bin/site.hs:31:12: Not in scope: ‘predicate’
bin/site.hs:58:12: Not in scope: ‘predicate’
Not in scope: ‘constA’
Perhaps you meant ‘const’ (imported from Prelude)
bin/site.hs:67:18: Not in scope: ‘setField’
bin/site.hs:68:13: Not in scope: ‘requireAllA’
bin/site.hs:69:13: Not in scope: ‘requireAllA’
Not in scope: ‘constA’
Perhaps you meant ‘const’ (imported from Prelude)
bin/site.hs:75:18: Not in scope: ‘setField’
bin/site.hs:76:13: Not in scope: ‘requireAllA’
Not in scope: ‘constA’
Perhaps you meant ‘const’ (imported from Prelude)
bin/site.hs:82:18: Not in scope: ‘setField’
bin/site.hs:83:13: Not in scope: ‘requireAllA’
bin/site.hs:91:9: Not in scope: ‘requireAll_’
Not in scope: type constructor or class ‘Resource’
Not in scope: type constructor or class ‘Resource’
bin/site.hs:115:40: Not in scope: type constructor or class ‘Page’
Not in scope: ‘readPage’
Perhaps you meant ‘readParen’ (imported from Prelude)
bin/site.hs:118:25: Not in scope: ‘addDefaultFields’
bin/site.hs:121:25: Not in scope: ‘pageRenderPandoc’
Not in scope: type constructor or class ‘Resource’
bin/site.hs:124:40: Not in scope: type constructor or class ‘Page’
Not in scope: ‘readPage’
Perhaps you meant ‘readParen’ (imported from Prelude)
bin/site.hs:128:25: Not in scope: ‘addDefaultFields’
bin/site.hs:131:25: Not in scope: ‘pageRenderPandoc’
bin/site.hs:155:14: Not in scope: type constructor or class ‘Page’
bin/site.hs:155:26: Not in scope: type constructor or class ‘Page’
bin/site.hs:156:32: Not in scope: ‘sortByBaseName’
bin/site.hs:159:18: Not in scope: ‘changeField’
Not in scope: ‘renderField’
Perhaps you meant ‘teaserField’ (imported from Hakyll)
bin/site.hs:164:23: Not in scope: type constructor or class ‘Page’
bin/site.hs:164:37: Not in scope: type constructor or class ‘Page’
bin/site.hs:164:52: Not in scope: type constructor or class ‘Page’
bin/site.hs:167:26: Not in scope: type constructor or class ‘Page’
bin/site.hs:167:40: Not in scope: type constructor or class ‘Page’
bin/site.hs:167:55: Not in scope: type constructor or class ‘Page’
bin/site.hs:170:48: Not in scope: type constructor or class ‘Page’
bin/site.hs:170:62: Not in scope: type constructor or class ‘Page’
bin/site.hs:170:77: Not in scope: type constructor or class ‘Page’
bin/site.hs:171:28: Not in scope: ‘setFieldA’
bin/site.hs:172:20: Not in scope: ‘sortByBaseName’
bin/site.hs:174:13: Not in scope: ‘require’
bin/site.hs:176:17: Not in scope: ‘pageBody’
Can someone help me get this to work? I'm not really a haskell guy, total
newb.
{-# LANGUAGE OverloadedStrings, Arrows #-}
module Main where
import Prelude hiding (id)
import Control.Category (id)
import Control.Arrow ((>>>), (>>^), (***), arr)
import Control.Monad (forM_)
import Data.Monoid (mempty, mconcat)
import System.FilePath
import Hakyll
main :: IO ()
main = hakyll $ do
-----------------------------------------------------------------------
-- compile templates
-----------------------------------------------------------------------
match "templates/*" $ compile templateCompiler
-----------------------------------------------------------------------
-- copy resources files & process css as necessary
-----------------------------------------------------------------------
match "resources/css/**" $ do
route $ setRoot `composeRoutes` setExtension "css"
compile sass
-- compile $ byExtension (error "not a valid css file")
-- [ (".css", sass)
-- , (".scss", sass) ]
match (predicate (\i -> matches "resources/**" i && not (matches
"resources/css/**" i))) $ do
route setRoot
compile copyFileCompiler
-- create site pages
-----------------------------------------------------------------------
forM_ indexPages $ \p -> match p $ do
route $ setRoot `composeRoutes` toIndex
compile $ unGitHubCompiler
= loadAndApplyTemplate "templates/page.html"
= loadAndApplyTemplate "templates/default.html"
forM_ markdownPages $ \p -> match p $ do
route $ setRoot `composeRoutes` cleanURL
compile $ unGitHubCompiler
= loadAndApplyTemplate "templates/page.html"
= loadAndApplyTemplate "templates/default.html"
match "p*/**/index.html" $ do
route setRoot
compile defaultCompiler
match "p*/***.html" $ do
route $ setRoot `composeRoutes` cleanURL
compile defaultCompiler
match (predicate (\i -> matches "p*/**" i && not (matches "*.m*d" i)))
$ do
route $ setRoot `composeRoutes` idRoute
compile copyFileCompiler
-- special root pages
-----------------------------------------------------------------------
match "index.html" $ route idRoute
create "index.html" $ constA mempty
= arr (setField "pagetitle" "Franklin De Los Santos")
= requireAllA "posts/***.md" (id *** arr newest10 >>= postList)
= requireAllA "projects/*/*.md" projectList
= loadAndApplyTemplate "templates/home.html"
= loadAndApplyTemplate "templates/default.html"
match "./posts/index.html" $ route idRoute
create "./posts/index.html" $ constA mempty
= arr (setField "pagetitle" "Posts - Franklin De Los Santos")
= requireAllA "posts/***.md" postList
= loadAndApplyTemplate "templates/posts.html"
= loadAndApplyTemplate "templates/default.html"
match "./projects/index.html" $ route idRoute
create "./projects/index.html" $ constA mempty
= arr (setField "pagetitle" "Projects - Franklin De Los Santos")
= requireAllA "projects/*/*.md" projectList
= loadAndApplyTemplate "templates/projects.html"
= loadAndApplyTemplate "templates/default.html"
-- render rss feed
-----------------------------------------------------------------------
match "atom.xml" $ route idRoute
create "atom.xml" $
requireAll_ "projects/*/*.md" >>= renderAtom feedConfiguration
where
indexPages = [ "p*/**README.*"
, "p*/**index.*" ]
markdownPages = [ "p*/***.md"
, "p*/***.mkd"
, "p*/***.mkdn"
, "p*/***.mdown"
, "p*/***.markdown"
, "p*/***.pandoc"
, "p*/***.pdc"
, "p*/***.lhs" ]
-----------------------------------------------------------------------
-- custom compilers
-----------------------------------------------------------------------
sass :: Compiler Resource String
sass = getResourceString >>= unixFilter "sass" ["-s", "--scss"]
= arr compressCss
unGitHub :: Compiler String String
unGitHub = unixFilter "sed"
["s+https://github.com/[^/]*/\\([^:/]*\\)/raw/master+/\\1+g"]
defaultCompiler :: Compiler Resource (Page String)
defaultCompiler = getResourceString
= arr readPage
= addDefaultFields
= arr applyAsTemplate
= arr buildTitle
= pageRenderPandoc
= loadAndApplyTemplate "templates/default.html"
unGitHubCompiler :: Compiler Resource (Page String)
unGitHubCompiler = getResourceString
= unGitHub
= arr readPage
= addDefaultFields
= arr applyAsTemplate
= arr buildTitle
= pageRenderPandoc
-- custom routes
-----------------------------------------------------------------------
setRoot :: Routes
setRoot = customRoute stripTopDir
stripTopDir :: Identifier -> FilePath
stripTopDir = joinPath . tail . splitPath . toFilePath
cleanURL :: Routes
cleanURL = customRoute fileToDirectory
fileToDirectory :: Identifier -> FilePath
fileToDirectory = (flip combine) "index.html" . dropExtension . toFilePath
toIndex :: Routes
toIndex = customRoute fileToIndex
fileToIndex :: Identifier -> FilePath
fileToIndex = (flip combine) "index.html" . dropFileName . toFilePath
-- misc functions
-----------------------------------------------------------------------
newest10 :: [Page a] -> [Page a]
newest10 = take 10 . reverse . sortByBaseName
stripIndexLink :: Item a -> Item a
stripIndexLink = changeField "url" dropFileName
buildTitle :: Item a -> Item a
buildTitle = renderField "title" "pagetitle" (++ " - Franklin De Los
Santos")
postList :: Compiler (Page String, [Page String]) (Page String)
postList = buildList "postlist" "templates/item.html"
projectList :: Compiler (Page String, [Page String]) (Page String)
projectList = buildList "projectlist" "templates/item.html"
buildList :: String -> Identifier -> Compiler (Page String, [Page String])
(Page String)
buildList field template = setFieldA field $
arr (reverse . sortByBaseName)
= arr (map stripIndexLink)
= require template (\p t -> map (applyTemplate t) p)
= arr mconcat
= arr pageBody
-- misc functions
-----------------------------------------------------------------------
feedConfiguration :: FeedConfiguration
feedConfiguration = FeedConfiguration
{ feedTitle = "fadelosa.com"
, feedDescription = "Projects & Posts from Franklin De Los Santos"
, feedAuthorName = "Franklin De Los Santos"
, feedRoot = "http://fadelosa.com"
}
I made some small changes, but I've been at this all night.
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...