1module Elm.Compiler.Module
2 ( Interface, Name(Name)
4 , nameToString, nameFromString
5 , hyphenate, dehyphenate
11import Control.Monad (mzero)
12import qualified Data.Aeson as Json
13import qualified Data.Char as Char
14import qualified Data.List as List
15import qualified Data.Map as Map
16import qualified Data.Text as Text
17import System.FilePath ((</>))
19import qualified AST.Module as Module
20import qualified Transform.AddDefaultImports as Defaults
23type Interface = Module.Interface
26newtype Name = Name [String]
30defaultImports :: [Name]
32 map Name (Map.keys Defaults.defaultImports)
35interfacePorts :: Interface -> [String]
36interfacePorts interface =
37 Module.iPorts interface
42nameToPath :: Name -> FilePath
43nameToPath (Name names) =
44 List.foldl1 (</>) names
47nameToString :: Name -> String
48nameToString (Name names) =
49 List.intercalate "." names
52nameFromString :: String -> Maybe Name
57hyphenate :: Name -> String
58hyphenate (Name names) =
59 List.intercalate "-" names
62dehyphenate :: String -> Maybe Name
67fromString :: Char -> String -> Maybe Name
69 Name `fmap` mapM isLegit names
72 filter (/= [sep]) (List.groupBy (\a b -> a /= sep && b /= sep) raw)
78 if Char.isUpper char && all legitChar rest
83 Char.isAlphaNum char || char `elem` "_'"
88instance Json.ToJSON Name where
90 Json.toJSON (nameToString name)
93instance Json.FromJSON Name where
94 parseJSON (Json.String text) =
95 let rawName = Text.unpack text in
96 case nameFromString rawName of
97 Nothing -> fail (rawName ++ " is not a valid module name")
98 Just name -> return name
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list