From cd246971582639666bb1afe1b51bbd3db1ac744a Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 2 Oct 2010 11:54:47 +0200 Subject: Disable partial functions (thanks chrisdone) --- src/Text/Hakyll/File.hs | 2 +- src/Text/Hakyll/Internal/CompressCss.hs | 4 ++-- src/Text/Hakyll/Internal/Page.hs | 6 +++--- src/Text/Hakyll/Internal/Template.hs | 6 ++---- src/Text/Hakyll/Util.hs | 6 +----- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs index 15903c7..57571e4 100644 --- a/src/Text/Hakyll/File.hs +++ b/src/Text/Hakyll/File.hs @@ -34,7 +34,7 @@ import Text.Hakyll.Internal.FileType (isRenderableFile) removeLeadingSeparator :: FilePath -> FilePath removeLeadingSeparator [] = [] removeLeadingSeparator path - | head path' `elem` pathSeparators = tail path' + | head path' `elem` pathSeparators = drop 1 path' | otherwise = path' where path' = if "$root" `isPrefixOf` path then drop 5 path diff --git a/src/Text/Hakyll/Internal/CompressCss.hs b/src/Text/Hakyll/Internal/CompressCss.hs index 4b19984..4a78791 100644 --- a/src/Text/Hakyll/Internal/CompressCss.hs +++ b/src/Text/Hakyll/Internal/CompressCss.hs @@ -29,8 +29,8 @@ stripComments :: String -> String stripComments [] = [] stripComments str | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str - | otherwise = head str : stripComments (tail str) + | otherwise = head str : stripComments (drop 1 str) where eatComments str' | null str' = [] | isPrefixOf "*/" str' = drop 2 str' - | otherwise = eatComments $ tail str' + | otherwise = eatComments $ drop 1 str' diff --git a/src/Text/Hakyll/Internal/Page.hs b/src/Text/Hakyll/Internal/Page.hs index 59bae65..92fb4fc 100644 --- a/src/Text/Hakyll/Internal/Page.hs +++ b/src/Text/Hakyll/Internal/Page.hs @@ -71,8 +71,8 @@ readSection _ _ [] = [] readSection renderFunction isFirst ls | not isDelimiter' = body ls | isNamedDelimiter = readSectionMetaData ls - | isFirst = readSimpleMetaData (tail ls) - | otherwise = body (tail ls) + | isFirst = readSimpleMetaData (drop 1 ls) + | otherwise = body (drop 1 ls) where isDelimiter' = isPossibleDelimiter (head ls) isNamedDelimiter = head ls `matchesRegex` "^----* *[a-zA-Z0-9][a-zA-Z0-9]*" @@ -80,7 +80,7 @@ readSection renderFunction isFirst ls readSimpleMetaData = map readPair . filter (not . all isSpace) readPair = trimPair . break (== ':') - trimPair (key, value) = (trim key, trim $ tail value) + trimPair (key, value) = (trim key, trim $ drop 1 value) readSectionMetaData [] = [] readSectionMetaData (header:value) = diff --git a/src/Text/Hakyll/Internal/Template.hs b/src/Text/Hakyll/Internal/Template.hs index bd9121b..15a2c8c 100644 --- a/src/Text/Hakyll/Internal/Template.hs +++ b/src/Text/Hakyll/Internal/Template.hs @@ -29,15 +29,13 @@ fromString = Template . fromString' fromString' [] = [] fromString' string | "$$" `isPrefixOf` string = - EscapeCharacter : (fromString' $ tail tail') + EscapeCharacter : (fromString' $ drop 2 string) | "$" `isPrefixOf` string = - let (key, rest) = span isAlphaNum tail' + let (key, rest) = span isAlphaNum $ drop 1 string in Identifier key : fromString' rest | otherwise = let (chunk, rest) = break (== '$') string in Chunk chunk : fromString' rest - where - tail' = tail string -- | Read a @Template@ from a file. This function might fetch the @Template@ -- from the cache, if available. diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs index 84d6257..e032c52 100644 --- a/src/Text/Hakyll/Util.hs +++ b/src/Text/Hakyll/Util.hs @@ -22,11 +22,7 @@ stripHtml :: String -> String stripHtml [] = [] stripHtml str = let (beforeTag, rest) = break (== '<') str (_, afterTag) = break (== '>') rest - in beforeTag ++ stripHtml (tail' afterTag) - where - -- We need a failsafe tail function. - tail' [] = [] - tail' xs = tail xs + in beforeTag ++ stripHtml (drop 1 afterTag) -- | Make a HTML link. -- -- cgit v1.2.3