on master help sign in
Allow outsiders to get the list of ports declared by a module
commit0c3034db4b6b7340d5a37aa6171787850a9b6de5 authorEvan Czaplicki <info@elm-lang.org> dateMon 17 Nov 2014, 16:04 (12 years ago) parentc422a7b
1 file changed+11
src/Elm/Compiler/Module.hs+11
src/Elm/Compiler/Module.hs+11
@@ -4,6 +4,7 @@ module Elm.Compiler.Module
44 , nameToString, nameFromString
55 , hyphenate, dehyphenate
66 , defaultImports
7+ , interfacePorts
78 )
89 where
910
@@ -21,6 +22,7 @@ import qualified Transform.AddDefaultImports as Defaults
2122
2223type Interface = Module.Interface
2324
25+
2426newtype Name = Name [String]
2527 deriving (Eq, Ord)
2628
@@ -30,6 +32,13 @@ defaultImports =
3032 map Name (Map.keys Defaults.defaultImports)
3133
3234
35+interfacePorts :: Interface -> [String]
36+interfacePorts interface =
37+ Module.iPorts interface
38+
39+
40+-- STRING CONVERSIONS
41+
3342nameToPath :: Name -> FilePath
3443nameToPath (Name names) =
3544 List.foldl1 (</>) names
@@ -74,6 +83,8 @@ fromString sep raw =
7483 Char.isAlphaNum char || char `elem` "_'"
7584
7685
86+-- JSON CONVERSIONS
87+
7788instance Json.ToJSON Name where
7889 toJSON name =
7990 Json.toJSON (nameToString name)