)
where
import Control.Applicative
+import Control.Monad
import qualified Data.Ascii as A
import Data.Attoparsec.Char8 as P
import qualified Data.Attoparsec.Lazy as LP
→ fail ("Failed to parse: " ⧺ fpath ⧺ ": " ⧺ e)
extMapP ∷ Parser [ (MIMEType, [Text]) ]
-extMapP = do xs ← P.many (comment <|> validLine <|> emptyLine)
+extMapP = do xs ← P.many (try comment <|> try validLine <|> emptyLine)
endOfInput
return $ catMaybes xs
where
isSpc c = c ≡ '\x20' ∨ c ≡ '\x09'
comment ∷ Parser (Maybe (MIMEType, [Text]))
- comment = try $
- do skipWhile isSpc
- _ ← char '#'
+ comment = do skipWhile isSpc
+ void $ char '#'
skipWhile (≢ '\x0A')
return Nothing
validLine ∷ Parser (Maybe (MIMEType, [Text]))
- validLine = try $
- do skipWhile isSpc
- mime ← mimeTypeP
+ validLine = do skipWhile isSpc
+ mime ← mimeType
skipWhile isSpc
exts ← sepBy extP (skipWhile isSpc)
return $ Just (mime, exts)
extP = decodeUtf8 <$> takeWhile1 (\c → (¬) (isSpc c ∨ c ≡ '\x0A'))
emptyLine ∷ Parser (Maybe (MIMEType, [Text]))
- emptyLine = try $
- do skipWhile isSpc
- _ ← char '\x0A'
+ emptyLine = do skipWhile isSpc
+ void $ char '\x0A'
return Nothing
compile ∷ Ord k ⇒ [(v, [k])] → Either (k, v, v) (Map k v)