From 311b3cc529097ef83a8212439dafcabb86534c62 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Sun, 28 Jun 2015 22:28:00 +0200 Subject: Prevent source parser from throwing exception when lexing fails. --- haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'haddock-api/src/Haddock') diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs index 6e195dba..bab5ba0a 100644 --- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs +++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs @@ -63,7 +63,9 @@ chunk str@(c:_) chunk str | "--" `isPrefixOf` str = chunk' $ spanToNewline str | "{-" `isPrefixOf` str = chunk' $ chunkComment 0 str - | otherwise = chunk' $ head $ lex str + | otherwise = case lex str of + (tok:_) -> chunk' tok + [] -> [str] where chunk' (c, rest) = c:(chunk rest) -- cgit v1.2.3