1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Elm.Compiler.Module
8 , interfaceAliasedTypes
22 , ModuleName.Canonical(..)
26import qualified Data.Char as Char
27import qualified Data.List as List
28import qualified Data.Map as Map
29import qualified Data.Text as Text
30import Data.Text (Text)
31import System.FilePath ((</>))
33import qualified AST.Module as Module
34import qualified AST.Module.Name as ModuleName
35import qualified Elm.Compiler.Type as PublicType
36import qualified Elm.Compiler.Type.Extract as Extract
37import qualified Json.Decode as Decode
38import qualified Json.Encode as Encode
45interfaceAliasedTypes :: Module.Interface -> Map.Map Text PublicType.Type
46interfaceAliasedTypes interface =
47 Map.map Extract.extract (Module.iTypes interface)
50programTypes :: Module.Interfaces -> ModuleName.Canonical -> Maybe PublicType.Program
52 Extract.extractProgram
59nameToPath :: ModuleName.Raw -> FilePath
61 List.foldl1 (</>) (map Text.unpack (Text.splitOn "." name))
64nameToString :: ModuleName.Raw -> String
69nameFromText :: Text -> Maybe ModuleName.Raw
74hyphenate :: ModuleName.Raw -> Text
76 Text.replace "." "-" name
79dehyphenate :: Text -> Maybe ModuleName.Raw
84fromText :: Char -> Text -> Maybe ModuleName.Raw
88 Text.splitOn (Text.singleton sep) name
90 if all isGoodChunk chunks then Just name else Nothing
93isGoodChunk :: Text -> Bool
95 case Text.uncons chunk of
100 Char.isUpper first && Text.all isGoodChar rest
103isGoodChar :: Char -> Bool
105 Char.isAlphaNum char || char == '_'
112encode :: ModuleName.Raw -> Encode.Value
117decoder :: Decode.Decoder ModuleName.Raw
119 do txt <- Decode.text
120 case nameFromText txt of
122 Decode.fail "a module name like \"Html.Events\""
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