From 357bc99bb13c68ffb6e1b10f6739fe5f753b9fe3 Mon Sep 17 00:00:00 2001 From: davve Date: Sun, 4 Feb 2007 17:37:08 +0000 Subject: Insert spaces around infix function names --- src/HaddockUtil.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/HaddockUtil.hs') diff --git a/src/HaddockUtil.hs b/src/HaddockUtil.hs index 4d67f0d7..1d962c82 100644 --- a/src/HaddockUtil.hs +++ b/src/HaddockUtil.hs @@ -20,7 +20,7 @@ module HaddockUtil ( -- * Miscellaneous utilities getProgramName, bye, die, dieMsg, noDieMsg, mapSnd, mapMaybeM, escapeStr, - nameOccString, moduleString, mkModuleNoPkg, + isConSym, isVarSym, nameOccString, moduleString, mkModuleNoPkg, -- * HTML cross reference mapping html_xrefs_ref, @@ -46,7 +46,7 @@ import Module import PackageConfig ( stringToPackageId ) import Control.Monad ( liftM, MonadPlus(..) ) -import Data.Char ( isAlpha, isSpace, toUpper, ord ) +import Data.Char import Data.IORef ( IORef, newIORef, readIORef ) import Data.List ( intersect, isSuffixOf, intersperse ) import Data.Maybe ( maybeToList, fromMaybe, isJust, fromJust ) @@ -231,6 +231,11 @@ escapeStr = flip escapeString unreserved escapeStr = escapeURIString isUnreserved #endif +-- there should be a better way to check this using the GHC API +isConSym n = head (nameOccString n) == ':' +isVarSym n = fstChar /= '_' && not (isConSym n) && (not . isLetter) fstChar + where fstChar = head (nameOccString n) + nameOccString = occNameString . nameOccName moduleString :: Module -> String -- cgit v1.2.3