1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Elm.Compiler.Module
8 , interfaceAliasedTypes
22 , ModuleName.Canonical(..)
27import qualified Data.Char as Char
28import qualified Data.List as List
29import qualified Data.Map as Map
30import qualified Data.Text as Text
31import Data.Text (Text)
32import System.FilePath ((</>))
34import qualified AST.Module as Module
35import qualified AST.Module.Name as ModuleName
36import qualified Elm.Compiler.Type as PublicType
37import qualified Elm.Compiler.Type.Extract as Extract
38import qualified Generate.JavaScript.Variable as JS
39import qualified Json.Decode as Decode
40import qualified Json.Encode as Encode
47interfaceAliasedTypes :: Module.Interface -> Map.Map Text PublicType.Type
48interfaceAliasedTypes interface =
49 Map.map Extract.extract (Module.iTypes interface)
52programTypes :: Module.Interfaces -> ModuleName.Canonical -> Maybe PublicType.Program
54 Extract.extractProgram
61nameToPath :: ModuleName.Raw -> FilePath
63 List.foldl1 (</>) (map Text.unpack (Text.splitOn "." name))
66nameToString :: ModuleName.Raw -> String
71nameFromText :: Text -> Maybe ModuleName.Raw
76hyphenate :: ModuleName.Raw -> Text
78 Text.replace "." "-" name
81dehyphenate :: Text -> Maybe ModuleName.Raw
86fromText :: Char -> Text -> Maybe ModuleName.Raw
90 Text.splitOn (Text.singleton sep) name
92 if all isGoodChunk chunks then Just name else Nothing
95isGoodChunk :: Text -> Bool
97 case Text.uncons chunk of
101 Just (first, rest) ->
102 Char.isUpper first && Text.all isGoodChar rest
105isGoodChar :: Char -> Bool
107 Char.isAlphaNum char || char == '_'
114encode :: ModuleName.Raw -> Encode.Value
119decoder :: Decode.Decoder ModuleName.Raw
121 do txt <- Decode.text
122 case nameFromText txt of
124 Decode.fail "Expecting a module name like \"Html.Events\""
134canonicalToMain :: ModuleName.Canonical -> Text
135canonicalToMain home =
136 JS.globalToName home "main"
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