]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
Applied HLint
authorpho <pho@cielonegro.org>
Mon, 12 Jan 2009 04:33:53 +0000 (13:33 +0900)
committerpho <pho@cielonegro.org>
Mon, 12 Jan 2009 04:33:53 +0000 (13:33 +0900)
darcs-hash:20090112043353-62b54-1d68c60f46a66e4afa8818c662aa7dc696e6f8f4.gz

13 files changed:
Main.hs
Rakka/Authorization.hs
Rakka/Environment.hs
Rakka/Storage/Impl.hs
Rakka/Storage/Repos.hs
Rakka/SystemConfig.hs
Rakka/W3CDateTime.hs
Rakka/Wiki/Interpreter/Base.hs
Rakka/Wiki/Interpreter/Outline.hs
Rakka/Wiki/Interpreter/PageList.hs
Rakka/Wiki/Interpreter/Trackback.hs
Rakka/Wiki/Parser.hs
tests/WikiParserTest.hs

diff --git a/Main.hs b/Main.hs
index 2ea8ef03d2d0091558e9e786f7b5869685878998..46eb3e2ad4867ef7361cb8c681a7ac2ac10d7f41 100644 (file)
--- a/Main.hs
+++ b/Main.hs
@@ -87,11 +87,11 @@ options = [ Option ['p'] ["port"]
 
           , Option [] ["disable-stderr-log"]
                    (NoArg OptDisableStderrLog)
-                   ("Disable logging to stderr.")
+                   "Disable logging to stderr."
 
           , Option [] ["rebuild-index"]
                    (NoArg OptRebuildIndex)
-                   ("Rebuild the index database.")
+                   "Rebuild the index database."
 
           , Option ['h'] ["help"]
                    (NoArg OptHelp)
@@ -111,7 +111,7 @@ main = withOpenSSL $
        withSubversion $
        do (opts, nonOpts, errors) <- return . getOpt Permute options =<< getArgs
 
-          when (not $ null errors)
+          unless (null errors)
                    $ do mapM_ putStr errors
                         exitWith $ ExitFailure 1
 
@@ -119,7 +119,7 @@ main = withOpenSSL $
                    $ do printUsage
                         exitWith ExitSuccess
 
-          when (not $ null nonOpts)
+          unless (null nonOpts)
                    $ do printUsage
                         exitWith $ ExitFailure 1
 
index be7f490e935b0f4e491069cbd1736e8c42298ed6..a7bcbea64025c5dc7fbf1cb5928b739381fb50b9 100644 (file)
@@ -88,9 +88,8 @@ loadUserMap :: FilePath -> IO UserMap
 loadUserMap path
     = do exist <- doesFileExist path
          m     <- if exist then
-                      readFile path
-                      >>=
-                      return . M.fromList . map decodePair . fromJust . deserializeStringPairs
+                      liftM (M.fromList . map decodePair . fromJust . deserializeStringPairs)
+                            (readFile path)
                   else
                       return M.empty
          sha1  <- return . fromJust =<< getDigestByName "SHA1"
index 1af20d1cc58b68206d9f9523ad0a9be23369f546..82694c257e9915fc464fe6b73ad1dc5f4ead3c22 100644 (file)
@@ -64,7 +64,7 @@ setupEnv lsdir portNum
          storage     <- mkStorage lsdir repos (makeDraft' interpTable)
          authDB      <- mkAuthDB lsdir
 
-         return Environment {
+         return Environment {
                       envLocalStateDir = lsdir
                     , envLucuConf      = lucuConf
                     , envRepository    = repos
index 442c412fb4966f906598155227c115dec48e75e2..e699163b6fcecdc5ee639f88c30868efa3b2a42c 100644 (file)
@@ -68,9 +68,7 @@ findAllPages repos rev = do reposPages   <- findAllPagesInRevision repos rev
 findChangedPages :: Repository -> RevNum -> RevNum -> IO (Set PageName)
 findChangedPages repos 0      newRev = findAllPages repos newRev
 findChangedPages repos oldRev newRev
-    = mapM (findChangedPagesAtRevision repos) [oldRev + 1 .. newRev]
-      >>=
-      return . S.unions
+    = liftM S.unions (mapM (findChangedPagesAtRevision repos) [oldRev + 1 .. newRev])
 
 
 getDirContents' :: Repository -> PageName -> Maybe RevNum -> IO [PageName]
@@ -210,13 +208,11 @@ searchIndex index cond
       fromId words docId
           = do uri     <- getDocURI index docId
                rev     <- unsafeInterleaveIO $
-                          getDocAttr index docId "rakka:revision"
-                          >>=
-                          return . read . fromJust
+                          liftM (read . fromJust)
+                                (getDocAttr index docId "rakka:revision")
                lastMod <- unsafeInterleaveIO $
-                          getDocAttr index docId "@mdate"
-                          >>=
-                          return . zonedTimeToUTC . fromJust . parseW3CDateTime . fromJust
+                          liftM (zonedTimeToUTC . fromJust . parseW3CDateTime . fromJust)
+                                (getDocAttr index docId "@mdate")
                summary <- unsafeInterleaveIO $
                           getDocAttr index docId "rakka:summary"
                snippet <- unsafeInterleaveIO $
@@ -267,7 +263,7 @@ updateIndexRev revFile f = withFile revFile ReadWriteMode update
                     rev  <- if eof then
                                 return 0
                             else
-                                hGetLine h >>= return . read
+                                liftM read (hGetLine h)
                     rev' <- f rev
                     hSeek h AbsoluteSeek 0
                     hSetFileSize h 0
index 1c5ef08abca28079845c0802dd34170d1551e624..8f49cbe4ad8c512004be6c52574276ef0427172d 100644 (file)
@@ -71,7 +71,7 @@ findAllPagesInRevision repos rev
 
       traverse :: FilePath -> Rev (Set PageName)
       traverse dir
-          = getDirEntries dir >>= mapM (traverse' dir) >>= return . S.unions
+          = liftM S.unions (getDirEntries dir >>= mapM (traverse' dir))
 
       traverse' :: FilePath -> DirEntry -> Rev (Set PageName)
       traverse' dir entry
@@ -104,7 +104,7 @@ getDirContentsInRevision repos dir rev
       path = mkDirPath dir
 
       getDir' :: Rev [PageName]
-      getDir' = getDirEntries path >>= return . map entToName
+      getDir' = liftM (map entToName) (getDirEntries path)
 
       entToName :: DirEntry -> PageName
       entToName = (dir </>) . decodePageName . dropExtension . entName
@@ -114,7 +114,7 @@ findChangedPagesAtRevision :: Repository -> RevNum -> IO (Set PageName)
 findChangedPagesAtRevision repos rev
     = do fs <- getRepositoryFS repos
          withRevision fs rev
-             $ getPathsChanged >>= return . foldl accumulatePages S.empty . map fst
+             $ liftM (foldl accumulatePages S.empty . map fst) getPathsChanged
     where
       accumulatePages :: Set PageName -> FilePath -> Set PageName
       accumulatePages s path
@@ -164,8 +164,8 @@ loadPageInRepository repos name rev
                               $ fmap chomp (lookup "svn:mime-type" props)
 
                lastMod <- unsafeIOToFS $
-                          getRevisionProp' fs pageRev "svn:date"
-                          >>= return . fromJust . parseW3CDateTime . chomp . fromJust
+                          liftM (fromJust . parseW3CDateTime . chomp . fromJust)
+                                (getRevisionProp' fs pageRev "svn:date")
 
                return Entity {
                             entityName       = name
@@ -199,11 +199,10 @@ loadPageInRepository repos name rev
                    dest    = chomp $ decodeString content
 
                lastMod <- unsafeIOToFS $
-                          getRevisionProp' fs pageRev "svn:date"
-                          >>= return . fromJust . parseW3CDateTime . chomp . fromJust
+                          liftM (fromJust . parseW3CDateTime . chomp . fromJust)
+                                (getRevisionProp' fs pageRev "svn:date")
 
-               isLocked <- getNodeProp path "rakka:isLocked"
-                           >>= return . isJust
+               isLocked <- liftM isJust (getNodeProp path "rakka:isLocked")
 
                return Redirection {
                             redirName       = name
@@ -242,11 +241,11 @@ putPageIntoRepository repos userID page
                                         case uiOldName ui of
                                           Nothing      -> return ()
                                           Just oldName -> do exists <- isFile (mkPagePath oldName)
-                                                             when (exists)
+                                                             when exists
                                                                   $ do movePage (uiOldRevision ui) oldName name
                                                                        moveAttachments (uiOldRevision ui) oldName name
                                         exists <- isFile (mkPagePath name)
-                                        unless (exists)
+                                        unless exists
                                                $ createPage name
                                         updatePage name
                             case ret of
@@ -425,7 +424,7 @@ loadAttachmentInRepository repos pName aName rev
       path = mkAttachmentPath pName aName
 
       loadAttachment' :: Rev a
-      loadAttachment' = getFileContents path >>= return . deserializeFromString . decodeString
+      loadAttachment' = liftM (deserializeFromString . decodeString) (getFileContents path)
 
 
 putAttachmentIntoRepository :: Attachment a =>
@@ -467,4 +466,4 @@ filterSvnError f = catchDyn f rethrow
           = let code = svnErrCode err
                 msg  = svnErrMsg  err
             in
-              fail $ "SvnError: " ++ (show code) ++ ": " ++ msg
+              fail $ "SvnError: " ++ show code ++ ": " ++ msg
index 91d9ca4178ed4f6f7b0a597d41662d0bc9e1e6ec..aa1e5798d24ee387bac9582797fc97d492d79a17 100644 (file)
@@ -72,7 +72,7 @@ class (Typeable a, Show a, Eq a) => SysConfValue a where
 mkSystemConfig :: LC.Config -> Repository -> IO SystemConfig
 mkSystemConfig lc repos
     = do cache <- newTVarIO M.empty
-         return SystemConfig {
+         return SystemConfig {
                       scLucuConf   = lc
                     , scRepository = repos
                     , scCache      = cache
@@ -192,7 +192,7 @@ serializeStringPairs = joinWith "\n" . map serializePair'
 
 
 deserializeStringPairs :: String -> Maybe [(String, String)]
-deserializeStringPairs = sequence . map deserializePair' . lines
+deserializeStringPairs = mapM deserializePair' . lines
     where
       deserializePair' :: String -> Maybe (String, String)
       deserializePair' s = case break (== ' ') s of
@@ -207,7 +207,7 @@ newtype SiteName = SiteName String deriving (Show, Typeable, Eq)
 instance SysConfValue SiteName where
     confPath _                = "siteName"
     serialize (SiteName name) = name
-    deserialize name          = Just (SiteName name)
+    deserialize               = Just . SiteName
     defaultValue _            = SiteName "Rakka"
 
 
@@ -241,7 +241,7 @@ newtype DefaultPage = DefaultPage String deriving (Show, Typeable, Eq)
 instance SysConfValue DefaultPage where
     confPath _                   = "defaultPage"
     serialize (DefaultPage name) = name
-    deserialize name             = Just (DefaultPage name)
+    deserialize                  = Just . DefaultPage
     defaultValue _               = DefaultPage "MainPage"
 
 
@@ -249,7 +249,7 @@ newtype StyleSheet = StyleSheet String deriving (Show, Typeable, Eq)
 instance SysConfValue StyleSheet where
     confPath _                  = "styleSheet"
     serialize (StyleSheet name) = name
-    deserialize name            = Just (StyleSheet name)
+    deserialize                 = Just . StyleSheet
     defaultValue _              = StyleSheet "StyleSheet/Default"
 
 
@@ -257,7 +257,7 @@ newtype Languages = Languages (Map LanguageTag LanguageName) deriving (Show, Typ
 instance SysConfValue Languages where
     confPath _                  = "languages"
     serialize (Languages langs) = serializeStringPairs (M.toList langs)
-    deserialize langs           = fmap (Languages . M.fromList) (deserializeStringPairs langs)
+    deserialize                 = fmap (Languages . M.fromList) . deserializeStringPairs
     defaultValue _         
         = Languages $ M.fromList [ ("en", "English"  )
                                  , ("es", "Español"  )
index 85af47a8e7f54feba299eef30d3dd5015ed6a9dd..595d228aee22db29c63951c95af21bf91113145e 100644 (file)
@@ -23,13 +23,13 @@ formatW3CDateTime zonedTime
                 timeOfDay          = localTimeOfDay localTime
                 (secInt, secFrac)  = properFraction (todSec timeOfDay)
             in
-              (printf "%04d-%02d-%02dT%02d:%02d:%02d"
-                      year
-                      month
-                      day
-                      (todHour timeOfDay)
-                      (todMin timeOfDay)
-                      (secInt :: Int))
+              printf "%04d-%02d-%02dT%02d:%02d:%02d"
+                     year
+                     month
+                     day
+                     (todHour timeOfDay)
+                     (todMin timeOfDay)
+                     (secInt :: Int))
               ++
               (if secFrac == 0
                then ""
@@ -38,9 +38,9 @@ formatW3CDateTime zonedTime
       formatTimeZone :: TimeZone -> String
       formatTimeZone tz
           = case timeZoneMinutes tz of
-              offset | offset <  0 -> '-':(showTZ $ negate offset)
+              offset | offset <  0 -> '-' : (showTZ $ negate offset)
                      | offset == 0 -> "Z"
-                     | otherwise   -> '+':(showTZ offset)
+                     | otherwise   -> '+' : showTZ offset
       
       showTZ :: Int -> String   
       showTZ offset
@@ -50,7 +50,7 @@ formatW3CDateTime zonedTime
               show2 hour ++ ":" ++ show2 minute
             
       show2 :: Int -> String
-      show2 n | n < 10    = '0':(show n)
+      show2 n | n < 10    = '0' : show n
               | otherwise = show n
 
 
index 2f6aade45ac6ba8a86f88d2daa12cb02841ed29e..5daba841ae7021abeabcff9ade57fc75baa29737 100644 (file)
@@ -93,7 +93,7 @@ otherLangsInterp
                                (langName, name) : mergeTables m xs
 
       mkLangList :: [(LanguageName, PageName)] -> BlockElement
-      mkLangList xs = List Bullet (map mkLangLink xs)
+      mkLangList = List Bullet . map mkLangLink
 
       mkLangLink :: (LanguageName, PageName) -> ListItem
       mkLangLink (langName, name)
index f6d798d295ce85b9f7eaf05193e543c4f68f3a78..983b4597cbb5d20d84c8bb878f2231bc0bf6b710 100644 (file)
@@ -27,15 +27,15 @@ mkOutline :: WikiPage -> BlockElement
 mkOutline tree = fst (mkOutline' emptyOutline 1 headings)
     where
       headings :: [BlockElement]
-      headings = concat (map collectInBlock tree)
+      headings = concatMap collectInBlock tree
 
       collectInBlock :: BlockElement -> [BlockElement]
       collectInBlock hd@(Heading _ _)
           = [hd]
       collectInBlock (Div _ xs)
-          = concat $ map collectInBlock $ catMaybes (map castToBlock xs)
+          = concatMap collectInBlock $ catMaybes (map castToBlock xs)
       collectInBlock (BlockCmd (BlockCommand _ _ xs))
-          = concat $ map collectInBlock xs
+          = concatMap collectInBlock xs
       collectInBlock _
           = []
 
index fd4d364ebde2ad6af3c7ae37f9bdfb72c935ad1d..3d5ce246b5e511f7de4f1f6623f54c0eb994cdee 100644 (file)
@@ -85,12 +85,11 @@ recentUpdatesInterp
       mkListItem :: Bool -> HitPage -> IO ListItem
       mkListItem showSummary page
           = do lastMod <- utcToLocalZonedTime (hpLastMod page)
-               return ( [ Inline ( PageLink {
-                                     linkPage     = Just (hpPageName page)
-                                   , linkFragment = Nothing
-                                   , linkText     = Nothing
-                                   }
-                                 )
+               return ( [ Inline PageLink {
+                                       linkPage     = Just (hpPageName page)
+                                     , linkFragment = Nothing
+                                     , linkText     = Nothing
+                                     }
                         , Block ( Div [("class", "date")]
                                   [Inline (Text (formatRFC1123DateTime lastMod))]
                                 )
index 485c46f1d6e343b48eece25ae6dc384ae146d36f..b5e5cf0270d9aa2acd50368af0dec79a9588fa83 100644 (file)
@@ -45,9 +45,8 @@ trackbacksInterp
                                Nothing
                                    -> return []
                                Just name
-                                   -> getAttachment (ctxStorage ctx) name "trackbacks" Nothing
-                                      >>=
-                                      return . fromMaybe []
+                                   -> liftM (fromMaybe [])
+                                            (getAttachment (ctxStorage ctx) name "trackbacks" Nothing)
                items <- mapM mkListItem trackbacks
 
                let divElem = Div [("class", "trackbacks")] [list]
index 912237c7eda8db5b2f7de3ca79e7ad5d257be6fd..33b68bd0ef0112df1b23f0ea7463a9e76e980f27 100644 (file)
@@ -53,7 +53,7 @@ heading = foldr (<|>) pzero (map heading' [1..5])
                       x  <- notFollowedBy (char '=') >> anyChar
                       xs <- manyTill anyChar (try $ ws >> ( count n (char '=')
                                                             <?>
-                                                            ("trailing " ++ take n (repeat '='))
+                                                            ("trailing " ++ replicate n '=')
                                                           )
                                              )
                       ws
@@ -88,7 +88,7 @@ listElement cmdTypeOf = listElement' []
                                  $ try $ do skipMany comment
                                             newline
                                             string stack
-                                            listElement' stack >>= return . Just
+                                            liftM Just (listElement' stack)
                        rest <- items stack
                        return $ (map Inline xs ++ map Block (catMaybes [nested])) : rest
                     <|>
@@ -108,7 +108,7 @@ listElement cmdTypeOf = listElement' []
 
 
 definitionList :: CommandTypeOf -> Parser BlockElement
-definitionList cmdTypeOf = many1 definition >>= return . DefinitionList
+definitionList cmdTypeOf = liftM DefinitionList (many1 definition)
     where
       definition :: Parser Definition
       definition = do char ';'
@@ -166,7 +166,7 @@ verbatim = do try (string "<!verbatim[")
 
 
 leadingSpaced :: CommandTypeOf -> Parser BlockElement
-leadingSpaced cmdTypeOf = (char ' ' >> leadingSpaced' >>= return . Preformatted)
+leadingSpaced cmdTypeOf = liftM Preformatted (char ' ' >> leadingSpaced')
                           <?>
                           "leading space"
     where
@@ -175,20 +175,19 @@ leadingSpaced cmdTypeOf = (char ' ' >> leadingSpaced' >>= return . Preformatted)
                           xs <- leadingSpaced'
                           return (x:xs)
                        <|>
-                       try ( newline
-                             >>
-                             char ' '
-                             >>
-                             leadingSpaced'
-                             >>=
-                             return . (Text "\n" :)
+                       try ( liftM (Text "\n" :) ( newline
+                                                   >>
+                                                   char ' '
+                                                   >>
+                                                   leadingSpaced'
+                                                 )
                            )
                        <|>
                        return []
 
 
 paragraph :: CommandTypeOf -> Parser BlockElement
-paragraph cmdTypeOf = paragraph' >>= return . Paragraph
+paragraph cmdTypeOf = liftM Paragraph paragraph'
     where
       paragraph' :: Parser [InlineElement]
       paragraph' = do x  <- inlineElement cmdTypeOf
@@ -224,7 +223,7 @@ blockCmd cmdTypeOf
                   Just BlockCommandType
                       -> do xs <- contents
                             closeTag tagName
-                            return $ BlockCmd BlockCommand {
+                            return $ BlockCmd BlockCommand {
                                          bCmdName       = tagName
                                        , bCmdAttributes = tagAttrs
                                        , bCmdContents   = xs
@@ -239,7 +238,7 @@ blockCmd cmdTypeOf
       (try $ do (tagName, tagAttrs) <- emptyTag
                 case cmdTypeOf tagName of
                   Just BlockCommandType
-                      -> return $ BlockCmd BlockCommand {
+                      -> return $ BlockCmd BlockCommand {
                                          bCmdName       = tagName
                                        , bCmdAttributes = tagAttrs
                                        , bCmdContents   = []
@@ -287,7 +286,7 @@ inlineElement cmdTypeOf
 
 
 nowiki :: Parser InlineElement
-nowiki = try (string "<!nowiki[") >> nowiki' >>= return . Text
+nowiki = liftM Text (try (string "<!nowiki[") >> nowiki')
     where
       nowiki' :: Parser String
       nowiki' = do try (string "]>")
@@ -299,18 +298,13 @@ nowiki = try (string "<!nowiki[") >> nowiki' >>= return . Text
 
 
 text :: Parser InlineElement
-text = ( char ':'
-         >>
-         many (noneOf ('\n':inlineSymbols))
-         >>=
-         return . Text . (':' :)
-         -- 定義リストとの關係上、コロンは先頭にしか來れない。
-       )
+text = liftM (Text . (':' :)) ( char ':'
+                                >>
+                                many (noneOf ('\n':inlineSymbols))
+                              )
+       -- 定義リストとの關係上、コロンは先頭にしか來られない。
        <|>
-       ( many1 (noneOf ('\n':inlineSymbols))
-         >>=
-         return . Text
-       )
+       liftM Text (many1 (noneOf ('\n':inlineSymbols)))
        <?>
        "text"
 
@@ -345,7 +339,7 @@ objLink :: Parser InlineElement
 objLink = do try (string "[[[")
              page  <- many1 (noneOf "|]")
              label <- option Nothing
-                      (char '|' >> many1 (satisfy (/= ']')) >>= return . Just)
+                      (liftM Just (char '|' >> many1 (satisfy (/= ']'))))
              string "]]]"
              return $ ObjectLink page label
           <?>
@@ -355,11 +349,11 @@ objLink = do try (string "[[[")
 pageLink :: Parser InlineElement
 pageLink = do try (string "[[")
               page     <- option Nothing 
-                          (many1 (noneOf "#|]") >>= return . Just)
+                          (liftM Just (many1 (noneOf "#|]")))
               fragment <- option Nothing
-                          (char '#' >> many1 (noneOf "|]") >>= return . Just)
+                          (liftM Just (char '#' >> many1 (noneOf "|]")))
               label    <- option Nothing
-                          (char '|' >> many1 (satisfy (/= ']')) >>= return . Just)
+                          (liftM Just (char '|' >> many1 (satisfy (/= ']'))))
 
               case (page, fragment) of
                 (Nothing, Nothing) -> pzero
@@ -376,7 +370,7 @@ extLink = do char '['
              uriStr <- many1 (noneOf " \t]")
              skipMany (oneOf " \t")
              label  <- option Nothing
-                       (many1 (noneOf "]") >>= return . Just)
+                       (liftM Just (many1 (noneOf "]")))
              
              case parseURI uriStr of
                Just uri -> char ']' >> return (ExternalLink uri label)
@@ -392,7 +386,7 @@ inlineCmd cmdTypeOf
                   Just InlineCommandType
                       -> do xs <- contents
                             closeTag tagName
-                            return $ InlineCmd InlineCommand {
+                            return $ InlineCmd InlineCommand {
                                          iCmdName       = tagName
                                        , iCmdAttributes = tagAttrs
                                        , iCmdContents   = xs
@@ -403,7 +397,7 @@ inlineCmd cmdTypeOf
       (try $ do (tagName, tagAttrs) <- emptyTag
                 case cmdTypeOf tagName of
                   Just InlineCommandType
-                      -> return $ InlineCmd InlineCommand {
+                      -> return $ InlineCmd InlineCommand {
                                          iCmdName       = tagName
                                        , iCmdAttributes = tagAttrs
                                        , iCmdContents   = []
@@ -420,7 +414,7 @@ inlineCmd cmdTypeOf
                  <|>
                  (comment >> contents)
                  <|>
-                 (newline >> contents >>= return . (Text "\n" :))
+                 liftM (Text "\n" :) (newline >> contents)
                  <|>
                  return []
 
@@ -477,14 +471,13 @@ comment = (try (string "<!--") >> skipTillEnd 1)
           "comment"
     where
       skipTillEnd :: Int -> Parser ()
-      skipTillEnd level = ( (try (string "<!--") >> skipTillEnd (level + 1))
-                            <|>
-                            (try (string "-->") >> case level of
-                                                     1 -> return ()
-                                                     n -> skipTillEnd (n - 1))
-                            <|>
-                            (anyChar >> skipTillEnd level)
-                          )
+      skipTillEnd level = (try (string "<!--") >> skipTillEnd (level + 1))
+                          <|>
+                          (try (string "-->") >> case level of
+                                                   1 -> return ()
+                                                   n -> skipTillEnd (n - 1))
+                          <|>
+                          (anyChar >> skipTillEnd level)
 
 
 blockSymbols :: [Char]
@@ -503,7 +496,6 @@ ws = skipMany ( (oneOf " \t" >> return ())
 
 -- end of line
 eol :: Parser ()
-eol = ( (newline >> return ())
-        <|>
-        eof
-      )
+eol = (newline >> return ())
+      <|>
+      eof
index a7c5c70087ecf9c41918ac06fdd847f94e4829d0..856707244b527a24356e048bd1c43f0e5211e3a1 100644 (file)
@@ -29,337 +29,337 @@ parseWiki src = case parse (wikiPage cmdTypeOf) "" src of
 testData :: [Test]
 testData = [ (parseWiki ""
               ~?=
-              (Right []))
+              Right [])
 
            , (parseWiki "\n"
               ~?=
-              (Right []))
+              Right [])
 
            , (parseWiki "=heading="
               ~?=
-              (Right [ Heading 1 "heading" ]))
+              Right [ Heading 1 "heading" ])
 
            , (parseWiki "==      heading  ==  \n"
               ~?=
-              (Right [ Heading 2 "heading" ]))
+              Right [ Heading 2 "heading" ])
 
            , (parseWiki "===== hello world =====\n"
               ~?=
-              (Right [ Heading 5 "hello world" ]))
+              Right [ Heading 5 "hello world" ])
 
            , (parseWiki "a =not a heading="
               ~?=
-              (Right [ Paragraph [ Text "a =not a heading=" ]
-                     ]))
+              Right [ Paragraph [ Text "a =not a heading=" ]
+                    ])
 
            , (parseWiki "=h=\n\n=h="
               ~?=
-              (Right [ Heading 1 "h"
-                     , Heading 1 "h"
-                     ]))
+              Right [ Heading 1 "h"
+                    , Heading 1 "h"
+                    ])
            , (parseWiki "foo\nbar"
               ~?=
-              (Right [ Paragraph [ Text "foo"
-                                 , Text "\n"
-                                 , Text "bar"
-                                 ]
-                     ]))
+              Right [ Paragraph [ Text "foo"
+                                , Text "\n"
+                                , Text "bar"
+                                ]
+                    ])
            , (parseWiki "foo\nbar\n\nbaz\n"
               ~?=
-              (Right [ Paragraph [ Text "foo"
-                                 , Text "\n"
-                                 , Text "bar"
-                                 ]
-                     , Paragraph [ Text "baz"
-                                 ]
-                     ]))
+              Right [ Paragraph [ Text "foo"
+                                , Text "\n"
+                                , Text "bar"
+                                ]
+                    , Paragraph [ Text "baz"
+                                ]
+                    ])
 
            , (parseWiki "foo\n\n\nbar"
               ~?=
-              (Right [ Paragraph [ Text "foo" ]
-                     , Paragraph [ Text "bar" ]
-                     ]))
+              Right [ Paragraph [ Text "foo" ]
+                    , Paragraph [ Text "bar" ]
+                    ])
 
            , (parseWiki "foo\n=h="
               ~?=
-              (Right [ Paragraph [ Text "foo" ]
-                     , Heading 1 "h"
-                     ]))
+              Right [ Paragraph [ Text "foo" ]
+                    , Heading 1 "h"
+                    ])
 
            , (parseWiki "<!-- comment -->"
               ~?=
-              (Right []))
+              Right [])
 
            , (parseWiki "<!-- comment -->foo"
               ~?=
-              (Right [ Paragraph [ Text "foo" ]
-                     ]))
+              Right [ Paragraph [ Text "foo" ]
+                    ])
 
            , (parseWiki "bar<!-- comment -->"
               ~?=
-              (Right [ Paragraph [ Text "bar" ]
-                     ]))
+              Right [ Paragraph [ Text "bar" ]
+                    ])
 
            , (parseWiki "foo<!-- comment -->bar"
               ~?=
-              (Right [ Paragraph [ Text "foo"
-                                 , Text "bar"
-                                 ]
-                     ]))
+              Right [ Paragraph [ Text "foo"
+                                , Text "bar"
+                                ]
+                    ])
 
            , (parseWiki "<!-- comment -->=h="
               ~?=
-              (Right [ Heading 1 "h" ]))
+              Right [ Heading 1 "h" ])
 
            , (parseWiki "=h= <!---->"
               ~?=
-              (Right [ Heading 1 "h" ]))
+              Right [ Heading 1 "h" ])
 
            , (parseWiki "<!-- <!-- nested --> comment -->"
               ~?=
-              (Right []))
+              Right [])
 
            , (parseWiki "[[[Page]]]"
               ~?=
-              (Right [ Paragraph [ ObjectLink "Page" Nothing ] ]))
+              Right [ Paragraph [ ObjectLink "Page" Nothing ] ])
 
            , (parseWiki "[[[Page|foo]]]"
               ~?=
-              (Right [ Paragraph [ ObjectLink "Page" (Just "foo") ] ]))
+              Right [ Paragraph [ ObjectLink "Page" (Just "foo") ] ])
 
            , (parseWiki "[[Page]]"
               ~?= 
-              (Right [ Paragraph [ PageLink (Just "Page") Nothing Nothing ]
-                     ]))
+              Right [ Paragraph [ PageLink (Just "Page") Nothing Nothing ]
+                    ])
 
            , (parseWiki "[[Page|Link to \"Page\"]]"
               ~?=
-              (Right [ Paragraph [ PageLink (Just "Page") Nothing (Just "Link to \"Page\"") ]
-                     ]))
+              Right [ Paragraph [ PageLink (Just "Page") Nothing (Just "Link to \"Page\"") ]
+                    ])
 
            , (parseWiki "[[Page#foo]]"
               ~?= 
-              (Right [ Paragraph [ PageLink (Just "Page") (Just "foo") Nothing ]
-                     ]))
+              Right [ Paragraph [ PageLink (Just "Page") (Just "foo") Nothing ]
+                    ])
 
            , (parseWiki "[[#foo]]"
               ~?= 
-              (Right [ Paragraph [ PageLink Nothing (Just "foo") Nothing ]
-                     ]))
+              Right [ Paragraph [ PageLink Nothing (Just "foo") Nothing ]
+                    ])
 
            , (parseWiki "[[Page#foo|Link to \"Page#foo\"]]"
               ~?=
-              (Right [ Paragraph [ PageLink (Just "Page") (Just "foo") (Just "Link to \"Page#foo\"") ]
-                     ]))
+              Right [ Paragraph [ PageLink (Just "Page") (Just "foo") (Just "Link to \"Page#foo\"") ]
+                    ])
 
            , (parseWiki "foo [[Bar]] baz"
               ~?=
-              (Right [ Paragraph [ Text "foo "
-                                 , PageLink (Just "Bar") Nothing Nothing
-                                 , Text " baz"
-                                 ]
-                     ]))
+              Right [ Paragraph [ Text "foo "
+                                , PageLink (Just "Bar") Nothing Nothing
+                                , Text " baz"
+                                ]
+                    ])
 
            , (parseWiki "[[Foo]]\n[[Bar]]"
               ~?= 
-              (Right [ Paragraph [ PageLink (Just "Foo") Nothing Nothing
-                                 , Text "\n"
-                                 , PageLink (Just "Bar") Nothing Nothing
-                                 ]
-                     ]))
+              Right [ Paragraph [ PageLink (Just "Foo") Nothing Nothing
+                                , Text "\n"
+                                , PageLink (Just "Bar") Nothing Nothing
+                                ]
+                    ])
 
            , (parseWiki " foo"
               ~?=
-              (Right [ Preformatted [ Text "foo" ] ]))
+              Right [ Preformatted [ Text "foo" ] ])
 
            , (parseWiki " foo\n  bar\n"
               ~?=
-              (Right [ Preformatted [ Text "foo"
-                                    , Text "\n"
-                                    , Text " bar"
-                                    ]
-                     ]))
+              Right [ Preformatted [ Text "foo"
+                                   , Text "\n"
+                                   , Text " bar"
+                                   ]
+                    ])
 
            , (parseWiki "foo\n bar\nbaz"
               ~?=
-              (Right [ Paragraph    [ Text "foo" ]
-                     , Preformatted [ Text "bar" ]
-                     , Paragraph    [ Text "baz" ]
-                     ]))
+              Right [ Paragraph    [ Text "foo" ]
+                    , Preformatted [ Text "bar" ]
+                    , Paragraph    [ Text "baz" ]
+                    ])
 
            , (parseWiki "----"
               ~?=
-              (Right [ HorizontalLine ]))
+              Right [ HorizontalLine ])
 
            , (parseWiki "\nfoo\nbar\n----\n"
               ~?=
-              (Right [ Paragraph [ Text "foo"
-                                 , Text "\n"
-                                 , Text "bar"
-                                 ]
-                     , HorizontalLine
-                     ]))
+              Right [ Paragraph [ Text "foo"
+                                , Text "\n"
+                                , Text "bar"
+                                ]
+                    , HorizontalLine
+                    ])
 
            , (parseWiki "a----b"
               ~?=
-              (Right [ Paragraph [ Text "a----b" ] ]))
+              Right [ Paragraph [ Text "a----b" ] ])
 
            , (parseWiki "* a"
               ~?=
-              (Right [ List Bullet [[Inline (Text "a")]] ]))
+              Right [ List Bullet [[Inline (Text "a")]] ])
 
            , (parseWiki "* a*"
               ~?=
-              (Right [ List Bullet [[Inline (Text "a*")]] ]))
+              Right [ List Bullet [[Inline (Text "a*")]] ])
 
            , (parseWiki "* a\n* b\n"
               ~?=
-              (Right [ List Bullet [ [Inline (Text "a")]
-                                   , [Inline (Text "b")]
-                                   ]
-                     ]))
+              Right [ List Bullet [ [Inline (Text "a")]
+                                  , [Inline (Text "b")]
+                                  ]
+                    ])
 
            , (parseWiki "*a\n*#b\n*#c\n"
               ~?=
-              (Right [ List Bullet [ [ Inline (Text "a")
-                                     , Block  (List Numbered [ [Inline (Text "b")]
-                                                             , [Inline (Text "c")]
-                                                             ])
-                                     ]
-                                   ]
-                     ]))
+              Right [ List Bullet [ [ Inline (Text "a")
+                                    , Block  (List Numbered [ [Inline (Text "b")]
+                                                            , [Inline (Text "c")]
+                                                            ])
+                                    ]
+                                  ]
+                    ])
 
            , (parseWiki "*a\n#b"
               ~?=
-              (Right [ List Bullet   [ [Inline (Text "a")] ]
-                     , List Numbered [ [Inline (Text "b")] ]
-                     ]))
+              Right [ List Bullet   [ [Inline (Text "a")] ]
+                    , List Numbered [ [Inline (Text "b")] ]
+                    ])
 
            , (parseWiki "*a<!-- comment -->"
               ~?=
-              (Right [ List Bullet [ [Inline (Text "a")] ] ]))
+              Right [ List Bullet [ [Inline (Text "a")] ] ])
 
            , (parseWiki "*a<!-- comment -->\n*b"
               ~?=
-              (Right [ List Bullet [ [Inline (Text "a")]
-                                   , [Inline (Text "b")]
-                                   ]
-                     ]))
+              Right [ List Bullet [ [Inline (Text "a")]
+                                  , [Inline (Text "b")]
+                                  ]
+                    ])
 
            , (parseWiki "foo:bar"
               ~?=
-              (Right [ Paragraph [ Text "foo"
-                                 , Text ":bar"
-                                 ]
-                     ]))
+              Right [ Paragraph [ Text "foo"
+                                , Text ":bar"
+                                ]
+                    ])
 
            , (parseWiki "; foo: bar"
               ~?=
-              (Right [ DefinitionList [Definition [Text "foo"] [Text "bar"]] ]))
+              Right [ DefinitionList [Definition [Text "foo"] [Text "bar"]] ])
 
            , (parseWiki "; foo: bar\n"
               ~?=
-              (Right [ DefinitionList [Definition [Text "foo"] [Text "bar"]] ]))
+              Right [ DefinitionList [Definition [Text "foo"] [Text "bar"]] ])
 
            , (parseWiki "; foo\n: bar\n; bar\n: baz\n: baz"
               ~?=
-              (Right [ DefinitionList [ Definition [Text "foo"] [ Text "bar" ]
-                                      , Definition [Text "bar"] [ Text "baz"
-                                                                , Text "\n"
-                                                                , Text "baz" ]
-                                      ]
-                     ]))
+              Right [ DefinitionList [ Definition [Text "foo"] [ Text "bar" ]
+                                     , Definition [Text "bar"] [ Text "baz"
+                                                               , Text "\n"
+                                                               , Text "baz" ]
+                                     ]
+                    ])
 
            , (parseWiki "<!nowiki[foo [[bar]] baz]>"
               ~?=
-              (Right [ Paragraph [ Text "foo [[bar]] baz" ] ]))
+              Right [ Paragraph [ Text "foo [[bar]] baz" ] ])
 
            , (parseWiki "<!verbatim[foo [[bar]] baz]>"
               ~?=
-              (Right [ Preformatted [ Text "foo [[bar]] baz" ] ]))
+              Right [ Preformatted [ Text "foo [[bar]] baz" ] ])
 
            , (parseWiki "<!verbatim[\nfoo [[bar]] baz\n]>"
               ~?=
-              (Right [ Preformatted [ Text "foo [[bar]] baz" ] ]))
+              Right [ Preformatted [ Text "foo [[bar]] baz" ] ])
 
            , (parseWiki "foo' bar"
               ~?=
-              (Right [ Paragraph [ Text "foo"
-                                 , Text "'"
-                                 , Text " bar" ]
-                     ]))
+              Right [ Paragraph [ Text "foo"
+                                , Text "'"
+                                , Text " bar" ]
+                    ])
 
            , (parseWiki "''foo''"
               ~?=
-              (Right [ Paragraph [ Italic [Text "foo"] ] ]))
+              Right [ Paragraph [ Italic [Text "foo"] ] ])
 
            , (parseWiki "'''foo'''"
               ~?=
-              (Right [ Paragraph [ Bold [Text "foo"] ] ]))
+              Right [ Paragraph [ Bold [Text "foo"] ] ])
 
            , (parseWiki "foo''''"
               ~?=
-              (Right [ Paragraph [ Text "foo"
-                                 , Text "'"
-                                 ]
-                     ]))
+              Right [ Paragraph [ Text "foo"
+                                , Text "'"
+                                ]
+                    ])
 
            , (parseWiki "'''''foo'''''"
               ~?=
-              (Right [ Paragraph [ Italic [Bold [Text "foo"]] ] ]))
+              Right [ Paragraph [ Italic [Bold [Text "foo"]] ] ])
 
            , (parseWiki "<br />"
               ~?=
-              (Right [ Paragraph [ InlineCmd (InlineCommand "br" [] []) ] ]))
+              Right [ Paragraph [ InlineCmd (InlineCommand "br" [] []) ] ])
 
            , (parseWiki "<br style=\"clear: both\"/>"
               ~?=
-              (Right [ Paragraph [ InlineCmd (InlineCommand "br" [("style", "clear: both")] []) ] ]))
+              Right [ Paragraph [ InlineCmd (InlineCommand "br" [("style", "clear: both")] []) ] ])
 
            , (parseWiki "<i><b>foo</b></i>"
               ~?=
-              (Right [ Paragraph [ InlineCmd (InlineCommand "i" []
-                                              [ InlineCmd (InlineCommand "b" [] [ Text "foo" ]) ]) ] ]))
+              Right [ Paragraph [ InlineCmd (InlineCommand "i" []
+                                             [ InlineCmd (InlineCommand "b" [] [ Text "foo" ]) ]) ] ])
 
            , (parseWiki "<i>\nfoo\n<!-- comment -->\nbar</i>"
               ~?=
-              (Right [ Paragraph [ InlineCmd (InlineCommand "i" []
-                                              [ Text "\n"
-                                              , Text "foo"
-                                              , Text "\n"
-                                              , Text "\n"
-                                              , Text "bar"
-                                              ]) ] ]))
+              Right [ Paragraph [ InlineCmd (InlineCommand "i" []
+                                             [ Text "\n"
+                                             , Text "foo"
+                                             , Text "\n"
+                                             , Text "\n"
+                                             , Text "bar"
+                                             ]) ] ])
 
            , (parseWiki "<div>foo</div>"
               ~?=
-              (Right [ BlockCmd (BlockCommand "div" []
-                                 [ Paragraph [Text "foo"] ]) ]))
+              Right [ BlockCmd (BlockCommand "div" []
+                                [ Paragraph [Text "foo"] ]) ])
 
            , (parseWiki "<div>\nbar\n</div>"
               ~?=
-              (Right [ BlockCmd (BlockCommand "div" []
-                                 [ Paragraph [Text "bar"] ]) ]))
+              Right [ BlockCmd (BlockCommand "div" []
+                                [ Paragraph [Text "bar"] ]) ])
 
            , (parseWiki "<div><!-- comment --></div>"
               ~?=
-              (Right [ BlockCmd (BlockCommand "div" [] []) ]))
+              Right [ BlockCmd (BlockCommand "div" [] []) ])
 
            , (parseWiki "foo<div id=\"bar\"/>"
               ~?=
-              (Right [ Paragraph [Text "foo"]
-                     , BlockCmd (BlockCommand "div" [("id", "bar")] [])
-                     ]))
+              Right [ Paragraph [Text "foo"]
+                    , BlockCmd (BlockCommand "div" [("id", "bar")] [])
+                    ])
 
            , (parseWiki "[http://example.org/]"
               ~?=
-              (Right [ Paragraph [ExternalLink (fromJust $ parseURI "http://example.org/") Nothing] ]))
+              Right [ Paragraph [ExternalLink (fromJust $ parseURI "http://example.org/") Nothing] ])
 
            , (parseWiki "[http://example.org/ example.org]"
               ~?=
-              (Right [ Paragraph [ExternalLink
-                                  (fromJust $ parseURI "http://example.org/")
-                                  (Just "example.org")
-                                 ]
-                     ]))
+              Right [ Paragraph [ExternalLink
+                                 (fromJust $ parseURI "http://example.org/")
+                                 (Just "example.org")
+                                ]
+                    ])
            ]