diff --git a/services/tazblog/shell.nix b/services/tazblog/shell.nix
index 196ffc983..021c3db31 100644
--- a/services/tazblog/shell.nix
+++ b/services/tazblog/shell.nix
@@ -7,5 +7,5 @@ let tazblog = import ./tazblog.nix;
ghc = pkgs.ghc.withPackages(p: map (x: p."${x}") depNames);
in pkgs.stdenv.mkDerivation {
name = "shell";
- buildInputs = [ ghc ];
+ buildInputs = [ ghc pkgs.hlint ];
}
diff --git a/services/tazblog/src/Blog.hs b/services/tazblog/src/Blog.hs
index 29fac37ac..0a53b5f2f 100644
--- a/services/tazblog/src/Blog.hs
+++ b/services/tazblog/src/Blog.hs
@@ -95,7 +95,7 @@ $maybe links <- pageLinks
^{links}
|]
where
- linkElems Entry {..} = concat $ ["/", show entryId]
+ linkElems Entry {..} = "/" ++ show entryId
showLinks :: Maybe Int -> Html
showLinks (Just i) =
@@ -134,7 +134,7 @@ renderEntry e@Entry {..} =
showError :: Text -> Text -> Html
showError title err =
blogTemplate (": " <> title)
- $ [shamlet|
+ [shamlet|
:(
#{err}
diff --git a/services/tazblog/src/BlogStore.hs b/services/tazblog/src/BlogStore.hs
index 195bcca0c..60ccd0b5a 100644
--- a/services/tazblog/src/BlogStore.hs
+++ b/services/tazblog/src/BlogStore.hs
@@ -85,7 +85,7 @@ withCache zone f = do
R.resolvConcurrent = True
}
seed <- R.makeResolvSeed conf
- R.withResolver seed $ (\r -> f $ BlogCache r zone)
+ R.withResolver seed (\r -> f $ BlogCache r zone)
listEntries :: MonadIO m => BlogCache -> Offset -> Count -> m [Entry]
listEntries cache offset count = liftIO $ do
@@ -97,7 +97,7 @@ listEntries cache offset count = liftIO $ do
$ sequence entries
getEntry :: MonadIO m => BlogCache -> EntryId -> m (Maybe Entry)
-getEntry cache eid = liftIO $ (entryFromDNS cache eid) >>= \case
+getEntry cache eid = liftIO $ entryFromDNS cache eid >>= \case
Left _ -> return Nothing -- TODO: ??
Right entry -> return $ Just entry
@@ -150,7 +150,7 @@ entryChunk (BlogCache r z) (EntryId eid) c =
fetchAssembleChunks :: BlogCache -> EntryId -> Meta -> IO (Either StoreError Text)
fetchAssembleChunks cache eid (Meta n _ _) = do
chunks <- mapM (entryChunk cache eid) [0 .. (n - 1)]
- return $ either Left (Right . T.concat) $ sequence chunks
+ return $ fmap T.concat $ sequence chunks
entryFromDNS :: BlogCache -> EntryId -> IO (Either StoreError Entry)
entryFromDNS cache eid = do
@@ -177,6 +177,6 @@ postList (BlogCache r z) =
let domain = encodeUtf8 ("_posts." <> z)
record = lookupTXT r domain
toPosts =
- fmap (sortBy (flip compare)) . sequence
- . map (\r -> maybe (Left InvalidPosts) Right (decodeStrict r))
- in record >>= return . either (Left . DNS) toPosts
+ fmap (sortBy (flip compare))
+ . mapM (maybe (Left InvalidPosts) Right . decodeStrict)
+ in either (Left . DNS) toPosts <$> record
diff --git a/services/tazblog/src/RSS.hs b/services/tazblog/src/RSS.hs
index 112dcc343..913aa9a40 100644
--- a/services/tazblog/src/RSS.hs
+++ b/services/tazblog/src/RSS.hs
@@ -6,7 +6,6 @@ module RSS
where
import BlogStore
-import Control.Monad (liftM)
import Data.Maybe (fromJust)
import qualified Data.Text as T
import Data.Time (UTCTime (..), getCurrentTime, secondsToDiffTime)
@@ -46,4 +45,4 @@ createFeed :: [Entry] -> IO RSS
createFeed e = getCurrentTime >>= (\t -> return $ createRSS t $ createItems e)
renderFeed :: [Entry] -> IO String
-renderFeed e = liftM (showXML . rssToXML) (createFeed e)
+renderFeed e = fmap (showXML . rssToXML) (createFeed e)
diff --git a/services/tazblog/src/Server.hs b/services/tazblog/src/Server.hs
index bec4d5290..401299883 100644
--- a/services/tazblog/src/Server.hs
+++ b/services/tazblog/src/Server.hs
@@ -1,6 +1,5 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Server where
@@ -22,12 +21,12 @@ tmpPolicy :: BodyPolicy
tmpPolicy = defaultBodyPolicy "/tmp" 0 200000 1000
runBlog :: Int -> String -> IO ()
-runBlog port respath = do
+runBlog port respath =
withCache "blog.tazj.in." $ \cache ->
simpleHTTP nullConf {port = port} $ tazblog cache respath
tazblog :: BlogCache -> String -> ServerPart Response
-tazblog cache resDir = do
+tazblog cache resDir =
msum
[ -- legacy language-specific routes
dir "de" $ blogHandler cache,
@@ -65,7 +64,7 @@ tryEntry (Just entry) = ok $ toResponse $ blogTemplate eTitle $ renderEntry entr
eTitle = T.append ": " (title entry)
offset :: Maybe Int -> Int
-offset = maybe 0 ((*) pageSize)
+offset = maybe 0 (pageSize *)
showIndex :: BlogCache -> ServerPart Response
showIndex cache = do