1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Elm.Compiler.Module
7 , interfaceAliasedTypes
21 , ModuleName.Canonical(..)
25import qualified Data.Char as Char
26import qualified Data.List as List
27import qualified Data.Map as Map
28import qualified Data.Text as Text
29import System.FilePath ((</>))
31import qualified AST.Module.Name as ModuleName
32import qualified Elm.Compiler.Type as Type
33import qualified Elm.Compiler.Type.Extract as Extract
34import qualified Elm.Interface as I
35import qualified Elm.Name as N
36import qualified Json.Decode as Decode
37import qualified Json.Encode as Encode
44interfaceAliasedTypes :: I.Interface -> Map.Map N.Name Type.Type
45interfaceAliasedTypes interface =
46 Map.map Extract.fromAnnotation (I._types interface)
49programTypes :: I.Interfaces -> ModuleName.Canonical -> Maybe Type.Program
61nameToPath :: Raw -> FilePath
63 List.foldl1 (</>) (map Text.unpack (Text.splitOn "." name))
66nameToString :: Raw -> String
71nameFromText :: Text.Text -> Maybe Raw
76hyphenate :: Raw -> Text.Text
78 Text.replace "." "-" name
81dehyphenate :: Text.Text -> Maybe Raw
86fromText :: Char -> Text.Text -> Maybe Raw
90 Text.splitOn (Text.singleton sep) name
92 if all isGoodChunk chunks then Just name else Nothing
95isGoodChunk :: Text.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 :: Raw -> Encode.Value
119decoder :: Decode.Decoder Raw
121 do txt <- Decode.text
122 case nameFromText txt of
124 Decode.fail "Expecting 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