1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Elm.Compiler.Module
8 , interfaceAliasedTypes
22 , ModuleName.Canonical(..)
27import qualified Data.Aeson as Json
28import qualified Data.Char as Char
29import qualified Data.List as List
30import qualified Data.Map as Map
31import qualified Data.Text as Text
32import Data.Text (Text)
33import System.FilePath ((</>))
35import qualified AST.Module as Module
36import qualified AST.Module.Name as ModuleName
37import qualified Elm.Compiler.Type as PublicType
38import qualified Elm.Compiler.Type.Extract as Extract
39import qualified Generate.JavaScript.Variable as Gen
46interfaceAliasedTypes :: Module.Interface -> Map.Map Text PublicType.Type
47interfaceAliasedTypes interface =
48 Map.map Extract.extract (Module.iTypes interface)
51programTypes :: Module.Interfaces -> ModuleName.Canonical -> Maybe PublicType.Program
53 Extract.extractProgram
60nameToPath :: ModuleName.Raw -> FilePath
62 List.foldl1 (</>) (map Text.unpack (Text.splitOn "." name))
65nameToString :: ModuleName.Raw -> String
70nameFromText :: Text -> Maybe ModuleName.Raw
75hyphenate :: ModuleName.Raw -> Text
77 Text.replace "." "-" name
80dehyphenate :: Text -> Maybe ModuleName.Raw
85fromText :: Char -> Text -> Maybe ModuleName.Raw
89 Text.splitOn (Text.singleton sep) name
91 if all isGoodChunk chunks then Just name else Nothing
94isGoodChunk :: Text -> Bool
96 case Text.uncons chunk of
100 Just (first, rest) ->
101 Char.isUpper first && Text.all isGoodChar rest
104isGoodChar :: Char -> Bool
106 Char.isAlphaNum char || char == '_'
114 RawForJson ModuleName.Raw
117fromJson :: RawForJson -> ModuleName.Raw
118fromJson (RawForJson raw) =
122instance Json.ToJSON RawForJson where
123 toJSON (RawForJson name) =
124 Json.toJSON (nameToString name)
127instance Json.FromJSON RawForJson where
128 parseJSON (Json.String text) =
129 case nameFromText text of
131 fail (Text.unpack text ++ " is not a valid module name")
134 return (RawForJson name)
137 fail "expecting the module name to be a string"
144qualifiedVar :: ModuleName.Canonical -> Text -> Text
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