1module Elm.Compiler.Module
2 ( Interface, Name(Name)
4 , nameToString, nameFromString
5 , hyphenate, dehyphenate
9import Control.Monad (mzero)
10import qualified Data.Aeson as Json
11import qualified Data.Char as Char
12import qualified Data.List as List
13import qualified Data.Text as Text
14import System.FilePath ((</>))
15import qualified AST.Module as Module
18type Interface = Module.Interface
20newtype Name = Name [String]
24nameToPath :: Name -> FilePath
25nameToPath (Name names) =
26 List.foldl1 (</>) names
29nameToString :: Name -> String
30nameToString (Name names) =
31 List.intercalate "." names
34nameFromString :: String -> Maybe Name
39hyphenate :: Name -> String
40hyphenate (Name names) =
41 List.intercalate "-" names
44dehyphenate :: String -> Maybe Name
49fromString :: Char -> String -> Maybe Name
51 Name `fmap` mapM isLegit names
54 filter (/= [sep]) (List.groupBy (\a b -> a /= sep && b /= sep) raw)
60 if Char.isUpper char && all legitChar rest
65 Char.isAlphaNum char || char `elem` "_'"
68instance Json.ToJSON Name where
70 Json.toJSON (nameToString name)
73instance Json.FromJSON Name where
74 parseJSON (Json.String text) =
75 let rawName = Text.unpack text in
76 case nameFromString rawName of
77 Nothing -> fail (rawName ++ " is not a valid module name")
78 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