about summary refs log tree commit diff
path: root/services
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-08-25T22·06+0100
committerVincent Ambo <tazjin@google.com>2019-08-25T22·07+0100
commit1247848d76712bad1e47b2b67969db3456f04e75 (patch)
tree6f10329c2e2eec1ac4284dfec70676b1c5080031 /services
parent561ed1fbbb624ddc51f5a97f4a81354e458e64cd (diff)
refactor(tazblog): Implement HLint lints in all files r/64
Diffstat (limited to 'services')
-rw-r--r--services/tazblog/shell.nix2
-rw-r--r--services/tazblog/src/Blog.hs4
-rw-r--r--services/tazblog/src/BlogStore.hs12
-rw-r--r--services/tazblog/src/RSS.hs3
-rw-r--r--services/tazblog/src/Server.hs7
5 files changed, 13 insertions, 15 deletions
diff --git a/services/tazblog/shell.nix b/services/tazblog/shell.nix
index 196ffc983a..021c3db31d 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 29fac37ac7..0a53b5f2fb 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|
 <p>:(
 <p>#{err}
 <hr>
diff --git a/services/tazblog/src/BlogStore.hs b/services/tazblog/src/BlogStore.hs
index 195bcca0c0..60ccd0b5a0 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 112dcc3438..913aa9a408 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 bec4d52909..4012998839 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