From 7e4c6988e433eb561bf0dbbb8d88503adf7c38bd Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 15 Oct 2002 13:17:40 +0000 Subject: [PATCH] [project @ 2002-10-15 13:17:40 by simonmar] Move looksLikeModuleName here from InterativeUI, so we can use it elsewhere. --- ghc/compiler/utils/Util.lhs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ghc/compiler/utils/Util.lhs b/ghc/compiler/utils/Util.lhs index 119ae82..9cc5c58 100644 --- a/ghc/compiler/utils/Util.lhs +++ b/ghc/compiler/utils/Util.lhs @@ -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} -- 1.7.10.4