on master help sign in
Allow upper case letter in package name and only normalize for equality and on disk
commit4878fe49e55b13a0c874499296e5529f5f517ace authorVincent Hanquez <vincent@snarc.org> dateWed 11 Oct 2017, 14:33 (9 years ago) parentaabe0e4
6 files changed+22−16
src/Idris/Imports.hs+14−7 src/Idris/Package.hs+2−2 src/Idris/Package/Parser.hs+1−1 src/Idris/Parser/Helpers.hs+2−2 src/Idris/REPL.hs+1−2 src/Idris/TypeSearch.hs+2−2
src/Idris/Imports.hs+14−7
@@ -18,7 +18,7 @@ import IRTS.System (getIdrisLibDir)
1818
1919import Control.Applicative ((<$>))
2020import Control.Monad.State.Strict
21−import Data.Char (isDigit, isLower)
21+import Data.Char (isDigit, isAlpha, toLower)
2222import Data.List (isSuffixOf)
2323import System.Directory
2424import System.FilePath
@@ -26,8 +26,15 @@ import System.FilePath
2626data IFileType = IDR FilePath | LIDR FilePath | IBC FilePath IFileType
2727 deriving (Show, Eq)
2828
29−newtype PkgName = PkgName { unPkgName :: String }
30− deriving (Show, Eq)
29+newtype PkgName = PkgName String
30+
31+unPkgName :: PkgName -> String
32+unPkgName (PkgName s) = map toLower s
33+
34+instance Show PkgName where
35+ show (PkgName pkg) = pkg
36+instance Eq PkgName where
37+ a == b = unPkgName a == unPkgName b
3138
3239unInitializedPkgName :: PkgName
3340unInitializedPkgName = PkgName ""
@@ -35,10 +42,10 @@ unInitializedPkgName = PkgName ""
3542pkgName :: String -> Either String PkgName
3643pkgName "" = Left "empty package name"
3744pkgName s@(f:l)
38− | not $ isLower f =
39− Left "package name need to start by a lower alpha"
40− | not $ all (\c -> isLower c || isDigit c || c `elem` "-_") l =
41− Left "package name need to contain only lower alpha, digits, and -_"
45+ | not $ isAlpha f =
46+ Left "package name need to start by a letter"
47+ | not $ all (\c -> isAlpha c || isDigit c || c `elem` "-_") l =
48+ Left "package name need to contain only letter, digits, and -_"
4249 | otherwise = Right $ PkgName s
4350
4451-- | Get the index file name for a package name
src/Idris/Package.hs+2−2
@@ -231,7 +231,7 @@ documentPkg copts (install,fp) = do
231231 pkgDocDir <- makeAbsolute (iDocDir </> unPkgName (pkgname pkgdesc))
232232 let out_dir = if install then pkgDocDir else outputDir
233233 when install $ do
234− putStrLn $ unwords ["Attempting to install IdrisDocs for", unPkgName $ pkgname pkgdesc, "in:", out_dir]
234+ putStrLn $ unwords ["Attempting to install IdrisDocs for", show $ pkgname pkgdesc, "in:", out_dir]
235235
236236 docRes <- generateDocs ist mods out_dir
237237 case docRes of
@@ -367,7 +367,7 @@ testLib warn p f
367367 case e of
368368 ExitSuccess -> return True
369369 _ -> do if warn
370− then do putStrLn $ "Not building " ++ unPkgName p ++
370+ then do putStrLn $ "Not building " ++ show p ++
371371 " due to missing library " ++ f
372372 return False
373373 else fail $ "Missing library " ++ f
src/Idris/Package/Parser.hs+1−1
@@ -145,7 +145,7 @@ pClause = do reserved "executable"; lchar '=';
145145 <|> do reserved "pkgs"; lchar '=';
146146 ps <- sepBy1 (pPkgName <* someSpace) (lchar ',')
147147 st <- get
148− let pkgs = pureArgParser $ concatMap (\x -> ["-p", unPkgName x]) ps
148+ let pkgs = pureArgParser $ concatMap (\x -> ["-p", show x]) ps
149149
150150 put (st { pkgdeps = ps `union` (pkgdeps st)
151151 , idris_opts = pkgs ++ idris_opts st})
src/Idris/Parser/Helpers.hs+2−2
@@ -398,8 +398,8 @@ operatorLetter = oneOf opChars
398398-- | Parse a package name
399399packageName :: MonadicParsing m => m String
400400packageName = (:) <$> oneOf firstChars <*> many (oneOf remChars)
401− where firstChars = ['a'..'z']
402− remChars = ['a'..'z'] ++ ['0'..'9'] ++ ['-','_']
401+ where firstChars = ['a'..'z'] ++ ['A'..'Z']
402+ remChars = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ ['-','_']
403403
404404commentMarkers :: [String]
405405commentMarkers = [ "--", "|||" ]
src/Idris/REPL.hs+1−2
@@ -65,7 +65,6 @@ import Idris.Help
6565import Idris.IBC
6666import qualified Idris.IdeMode as IdeMode
6767import Idris.IdrisDoc
68−import Idris.Imports
6968import Idris.Info
7069import Idris.Inliner
7170import Idris.Interactive
@@ -1374,7 +1373,7 @@ process fn (SetPrinterDepth d) = setDepth d
13741373process fn (Apropos pkgs a) =
13751374 do orig <- getIState
13761375 when (not (null pkgs)) $
1377− iputStrLn $ "Searching packages: " ++ showSep ", " (map unPkgName pkgs)
1376+ iputStrLn $ "Searching packages: " ++ showSep ", " (map show pkgs)
13781377 mapM_ loadPkgIndex pkgs
13791378 ist <- getIState
13801379 let mods = aproposModules ist (T.pack a)
src/Idris/TypeSearch.hs+2−2
@@ -26,7 +26,7 @@ import Idris.Delaborate (delabTy)
2626import Idris.Docstrings (noDocs, overview)
2727import Idris.Elab.Type (elabType)
2828import Idris.IBC
29−import Idris.Imports (PkgName, unPkgName)
29+import Idris.Imports (PkgName)
3030import Idris.Output (iPrintResult, iRenderError, iRenderOutput, iRenderResult,
3131 iputStrLn, prettyDocumentedIst)
3232
@@ -53,7 +53,7 @@ searchByType :: [PkgName] -> PTerm -> Idris ()
5353searchByType pkgs pterm = do
5454 i <- getIState -- save original
5555 when (not (null pkgs)) $
56− iputStrLn $ "Searching packages: " ++ showSep ", " (map unPkgName pkgs)
56+ iputStrLn $ "Searching packages: " ++ showSep ", " (map show pkgs)
5757
5858 mapM_ loadPkgIndex pkgs
5959 pterm' <- addUsingConstraints syn emptyFC pterm