[project @ 2002-10-15 13:17:40 by simonmar]
authorsimonmar <unknown>
Tue, 15 Oct 2002 13:17:40 +0000 (13:17 +0000)
committersimonmar <unknown>
Tue, 15 Oct 2002 13:17:40 +0000 (13:17 +0000)
Move looksLikeModuleName here from InterativeUI, so we can use it elsewhere.

ghc/compiler/utils/Util.lhs

index 119ae82..9cc5c58 100644 (file)
@@ -44,6 +44,9 @@ module Util (
        unzipWith,
 
        global,
+
+       -- module names
+       looksLikeModuleName,
     ) where
 
 #include "../includes/config.h"
@@ -64,6 +67,8 @@ import qualified List ( elem, notElem )
 import List            ( zipWith4 )
 #endif
 
+import Char            ( isUpper, isAlphaNum )
+
 infixr 9 `thenCmp`
 \end{code}
 
@@ -782,3 +787,12 @@ Global variables:
 global :: a -> IORef a
 global a = unsafePerformIO (newIORef a)
 \end{code}
+
+Module names:
+
+\begin{code}
+looksLikeModuleName [] = False
+looksLikeModuleName (c:cs) = isUpper c && all isAlphaNumEx cs
+
+isAlphaNumEx c = isAlphaNum c || c == '_' || c == '.'
+\end{code}