-extMapP ∷ Parser [(MIMEType, [Text])]
-extMapP = catMaybes <$> P.many (try comment <|> try validLine <|> emptyLine)
- where
- isSpc ∷ Char → Bool
- isSpc c = c ≡ '\x20' ∨ c ≡ '\x09'
-
- comment ∷ Parser (Maybe (MIMEType, [Text]))
- comment = do skipWhile isSpc
- void $ char '#'
- skipWhile (≢ '\x0A')
- return Nothing
-
- validLine ∷ Parser (Maybe (MIMEType, [Text]))
- validLine = do skipWhile isSpc
- mime ← mimeType
- skipWhile isSpc
- exts ← sepBy extP (skipWhile isSpc)
- return $ Just (mime, exts)
+ pair ∷ Parser (MIMEType, [Text])
+ pair = do skipSpace
+ mime ← def
+ skipSpace1
+ exts ← sepBy1 ext $ skipWhile1 (≡ '\x20')
+ return (mime, exts)
+ <?>
+ "pair"