Skip to content

Commit b938f71

Browse files
committed
use ModulePath instead of [ProperName]
1 parent 1821620 commit b938f71

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Language/PureScript/Declarations.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import qualified Data.Map as M
2828
import qualified Text.Parsec as P
2929
import qualified Text.Parsec.Pos as P
3030

31+
import Language.PureScript.Names
3132
import Language.PureScript.Values
3233
import Language.PureScript.Types
3334
import Language.PureScript.Parser.State
@@ -100,13 +101,16 @@ parseImportDeclaration :: P.Parsec String ParseState Declaration
100101
parseImportDeclaration = 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

111115
parseDeclaration :: P.Parsec String ParseState Declaration
112116
parseDeclaration = P.choice

0 commit comments

Comments
 (0)