aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-28 22:28:00 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-30 22:37:49 +0200
commit311b3cc529097ef83a8212439dafcabb86534c62 (patch)
treed83b2cc59eb4acf4b99822e2f775945091be88b0 /haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
parent4a6b6c18dbb6542b64f13e4f51cc0447df15a175 (diff)
Prevent source parser from throwing exception when lexing fails.
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs4
1 files changed, 3 insertions, 1 deletions
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)