on master help sign in
Disable partial functions (thanks chrisdone)
cd24697Jasper Van der Jeugt
src/Text/Hakyll/File.hs+1−1
@@ -34,7 +34,7 @@ import Text.Hakyll.Internal.FileType (isRenderableFile)
34removeLeadingSeparator :: FilePath -> FilePath
34removeLeadingSeparator :: FilePath -> FilePath
35removeLeadingSeparator [] = []
35removeLeadingSeparator [] = []
36removeLeadingSeparator path
36removeLeadingSeparator path
37− | head path' `elem` pathSeparators = tail path'
37+ | head path' `elem` pathSeparators = drop 1 path'
38 | otherwise = path'
38 | otherwise = path'
39 where
39 where
40 path' = if "$root" `isPrefixOf` path then drop 5 path
40 path' = if "$root" `isPrefixOf` path then drop 5 path
src/Text/Hakyll/Internal/CompressCss.hs+2−2
@@ -29,8 +29,8 @@ stripComments :: String -> String
29stripComments [] = []
29stripComments [] = []
30stripComments str
30stripComments str
31 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
31 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
32− | otherwise = head str : stripComments (tail str)
32+ | otherwise = head str : stripComments (drop 1 str)
33 where
33 where
34 eatComments str' | null str' = []
34 eatComments str' | null str' = []
35 | isPrefixOf "*/" str' = drop 2 str'
35 | isPrefixOf "*/" str' = drop 2 str'
36− | otherwise = eatComments $ tail str'
36+ | otherwise = eatComments $ drop 1 str'
src/Text/Hakyll/Internal/Page.hs+3−3
@@ -71,8 +71,8 @@ readSection _ _ [] = []
71readSection renderFunction isFirst ls
71readSection renderFunction isFirst ls
72 | not isDelimiter' = body ls
72 | not isDelimiter' = body ls
73 | isNamedDelimiter = readSectionMetaData ls
73 | isNamedDelimiter = readSectionMetaData ls
74− | isFirst = readSimpleMetaData (tail ls)
74+ | isFirst = readSimpleMetaData (drop 1 ls)
75− | otherwise = body (tail ls)
75+ | otherwise = body (drop 1 ls)
76 where
76 where
77 isDelimiter' = isPossibleDelimiter (head ls)
77 isDelimiter' = isPossibleDelimiter (head ls)
78 isNamedDelimiter = head ls `matchesRegex` "^----* *[a-zA-Z0-9][a-zA-Z0-9]*"
78 isNamedDelimiter = head ls `matchesRegex` "^----* *[a-zA-Z0-9][a-zA-Z0-9]*"
@@ -80,7 +80,7 @@ readSection renderFunction isFirst ls
80
80
81 readSimpleMetaData = map readPair . filter (not . all isSpace)
81 readSimpleMetaData = map readPair . filter (not . all isSpace)
82 readPair = trimPair . break (== ':')
82 readPair = trimPair . break (== ':')
83− trimPair (key, value) = (trim key, trim $ tail value)
83+ trimPair (key, value) = (trim key, trim $ drop 1 value)
84
84
85 readSectionMetaData [] = []
85 readSectionMetaData [] = []
86 readSectionMetaData (header:value) =
86 readSectionMetaData (header:value) =
src/Text/Hakyll/Internal/Template.hs+2−4
@@ -29,15 +29,13 @@ fromString = Template . fromString'
29 fromString' [] = []
29 fromString' [] = []
30 fromString' string
30 fromString' string
31 | "$$" `isPrefixOf` string =
31 | "$$" `isPrefixOf` string =
32− EscapeCharacter : (fromString' $ tail tail')
32+ EscapeCharacter : (fromString' $ drop 2 string)
33 | "$" `isPrefixOf` string =
33 | "$" `isPrefixOf` string =
34− let (key, rest) = span isAlphaNum tail'
34+ let (key, rest) = span isAlphaNum $ drop 1 string
35 in Identifier key : fromString' rest
35 in Identifier key : fromString' rest
36 | otherwise =
36 | otherwise =
37 let (chunk, rest) = break (== '$') string
37 let (chunk, rest) = break (== '$') string
38 in Chunk chunk : fromString' rest
38 in Chunk chunk : fromString' rest
39− where
40− tail' = tail string
41
39
42-- | Read a @Template@ from a file. This function might fetch the @Template@
40-- | Read a @Template@ from a file. This function might fetch the @Template@
43-- from the cache, if available.
41-- from the cache, if available.
src/Text/Hakyll/Util.hs+1−5
@@ -22,11 +22,7 @@ stripHtml :: String -> String
22stripHtml [] = []
22stripHtml [] = []
23stripHtml str = let (beforeTag, rest) = break (== '<') str
23stripHtml str = let (beforeTag, rest) = break (== '<') str
24 (_, afterTag) = break (== '>') rest
24 (_, afterTag) = break (== '>') rest
25− in beforeTag ++ stripHtml (tail' afterTag)
25+ in beforeTag ++ stripHtml (drop 1 afterTag)
26− where
27− -- We need a failsafe tail function.
28− tail' [] = []
29− tail' xs = tail xs
30
26
31-- | Make a HTML link.
27-- | Make a HTML link.
32--
28--