moduleText.Hakyll(hakyll)whereimportNetwork.Hakyll.SimpleServer(simpleServer)importSystem.Environment(getArgs,getProgName)importSystem.Directory(doesDirectoryExist,removeDirectoryRecursive)-- | Main function to run hakyll.hakyll::IO()->IO()hakyllbuildFunction=doargs<-getArgscaseargsof[]->buildbuildFunction["clean"]->clean["preview",p]->buildbuildFunction>>server(readp)["preview"]->buildbuildFunction>>server8000["server",p]->server(readp)["server"]->server8000_->help-- | Build the site.build::IO()->IO()buildbuildFunction=doputStrLn"Generating..."buildFunction-- | Clean up directories.clean::IO()clean=doremove'"_cache"remove'"_site"whereremove'dir=doputStrLn$"Removing "++dir++"..."exists<-doesDirectoryExistdirifexiststhenremoveDirectoryRecursivedirelsereturn()-- | Show usage information.help::IO()help=doname<-getProgNameputStrLn$"This is a hakyll site generator program. You should always\n"++"run it from the project root directory.\n"++"\n"++"Usage:\n"++name++" Generate the site.\n"++name++" clean Clean up and remove cache.\n"++name++" help Show this message.\n"++name++" preview [port] Generate site, then start a server.\n"++name++" server [port] Run a local test server.\n"server::Integer->IO()serverp=dosimpleServer(fromIntegral$p)"_site"