git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
use ModulePath instead of [ProperName]
commitb938f712d6e368d624528ea16002d699de540685 authorBogdan Popa <popa.bogdanp@gmail.com> dateSat 16 Nov 2013, 21:07 (13 years ago) parent1821620
2 files changed+7−3
src/Language/PureScript/Declarations.hs+1−1 src/Language/PureScript/Parser/Declarations.hs+6−2
src/Language/PureScript/Declarations.hs+1−1
@@ -39,5 +39,5 @@ data Declaration
3939 | ExternDataDeclaration ProperName Kind
4040 | FixityDeclaration Fixity String
4141 | ModuleDeclaration ProperName [Declaration]
42− | ImportDeclaration [ProperName] (Maybe [Ident])
42+ | ImportDeclaration ModulePath (Maybe [Ident])
4343 deriving (Show, D.Data, D.Typeable)
src/Language/PureScript/Parser/Declarations.hs+6−2
@@ -28,6 +28,7 @@ import qualified Data.Map as M
2828import qualified Text.Parsec as P
2929import qualified Text.Parsec.Pos as P
3030
31+import Language.PureScript.Names
3132import Language.PureScript.Values
3233import Language.PureScript.Types
3334import Language.PureScript.Parser.State
@@ -100,13 +101,16 @@ parseImportDeclaration :: P.Parsec String ParseState Declaration
100101parseImportDeclaration = do
101102 reserved "import"
102103 indented
103− module_ <- P.sepBy1 properName (lexeme $ P.char '.')
104+ segments <- P.sepBy1 properName (lexeme $ P.char '.')
104105 idents <- P.optionMaybe $ do
105106 lexeme $ indented *> P.char '('
106107 idents <- P.sepBy1 parseIdent (lexeme $ indented *> P.char ',')
107108 lexeme $ indented *> P.char ')'
108109 return idents
109− return $ ImportDeclaration module_ idents
110+ let modulePath = (mkModulePath (ModulePath [head segments]) (tail segments))
111+ return $ ImportDeclaration modulePath idents
112+ where mkModulePath path (s:ss) = mkModulePath (subModule path s) ss
113+ mkModulePath path _ = path
110114
111115parseDeclaration :: P.Parsec String ParseState Declaration
112116parseDeclaration = P.choice