1module Elm.Compiler.Module
2 ( Interface, Interfaces
5 , nameToString, nameFromString
6 , hyphenate, dehyphenate
7 , RawForJson(RawForJson), fromJson
9 , interfaceAliasedTypes
10 , ModuleName.Canonical(..), qualifiedVar
14import qualified Data.Aeson as Json
15import qualified Data.Char as Char
16import qualified Data.List as List
17import qualified Data.Map as Map
18import qualified Data.Text as Text
19import System.FilePath ((</>))
21import qualified AST.Module as Module
22import qualified AST.Module.Name as ModuleName
23import qualified Elm.Compiler.Imports as Imports
24import qualified Elm.Compiler.Type as Type
25import qualified Elm.Compiler.Type.Extract as Extract
26import qualified Generate.JavaScript.Variable as Gen
33type Interface = Module.Interface
36type Interfaces = Module.Interfaces
39interfaceAliasedTypes :: Interface -> Map.Map String Type.Type
40interfaceAliasedTypes interface =
41 Map.map Extract.toAliasedType (Module.iTypes interface)
48newtype RawForJson = RawForJson ModuleName.Raw
51fromJson :: RawForJson -> ModuleName.Raw
52fromJson (RawForJson raw) =
56qualifiedVar :: ModuleName.Canonical -> String -> String
61defaultImports :: [ModuleName.Raw]
63 map fst Imports.defaults
67-- STRING CONVERSIONS for RAW NAMES
70nameToPath :: ModuleName.Raw -> FilePath
72 List.foldl1 (</>) names
75nameToString :: ModuleName.Raw -> String
77 List.intercalate "." names
80nameFromString :: String -> Maybe ModuleName.Raw
85hyphenate :: ModuleName.Raw -> String
87 List.intercalate "-" names
90dehyphenate :: String -> Maybe ModuleName.Raw
95fromString :: Char -> String -> Maybe ModuleName.Raw
100 filter (/= [sep]) (List.groupBy (\a b -> a /= sep && b /= sep) raw)
106 if Char.isUpper char && all legitChar rest
111 Char.isAlphaNum char || char `elem` "_'"
118instance Json.ToJSON RawForJson where
119 toJSON (RawForJson name) =
120 Json.toJSON (nameToString name)
123instance Json.FromJSON RawForJson where
124 parseJSON (Json.String text) =
129 case nameFromString rawString of
131 fail (rawString ++ " is not a valid module name")
134 return (RawForJson name)
137 fail "expecting the module name to be a string"
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