1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Elm.Compiler.Module
8 , interfaceAliasedTypes
22 , ModuleName.Canonical(..)
26import qualified Data.Aeson as Json
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
44interfaceAliasedTypes :: Module.Interface -> Map.Map Text PublicType.Type
45interfaceAliasedTypes interface =
46 Map.map Extract.extract (Module.iTypes interface)
49programTypes :: Module.Interfaces -> ModuleName.Canonical -> Maybe PublicType.Program
51 Extract.extractProgram
58nameToPath :: ModuleName.Raw -> FilePath
60 List.foldl1 (</>) (map Text.unpack (Text.splitOn "." name))
63nameToString :: ModuleName.Raw -> String
68nameFromText :: Text -> Maybe ModuleName.Raw
73hyphenate :: ModuleName.Raw -> Text
75 Text.replace "." "-" name
78dehyphenate :: Text -> Maybe ModuleName.Raw
83fromText :: Char -> Text -> Maybe ModuleName.Raw
87 Text.splitOn (Text.singleton sep) name
89 if all isGoodChunk chunks then Just name else Nothing
92isGoodChunk :: Text -> Bool
94 case Text.uncons chunk of
99 Char.isUpper first && Text.all isGoodChar rest
102isGoodChar :: Char -> Bool
104 Char.isAlphaNum char || char == '_'
112 RawForJson ModuleName.Raw
115fromJson :: RawForJson -> ModuleName.Raw
116fromJson (RawForJson raw) =
120instance Json.ToJSON RawForJson where
121 toJSON (RawForJson name) =
122 Json.toJSON (nameToString name)
125instance Json.FromJSON RawForJson where
126 parseJSON (Json.String text) =
127 case nameFromText text of
129 fail (Text.unpack text ++ " is not a valid module name")
132 return (RawForJson name)
135 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