#2362: allow full import syntax in GHCi
---------------------------------+------------------------------------------
Reporter: Isaac Dupree | Owner: igloo
Type: feature request | Status: new
Priority: high | Milestone: 6.14.1
Component: Compiler | Version: 6.8.2
Keywords: ghci, import | Difficulty: Unknown
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by simonmar):
Many thanks for the patch! I've done a patch review, there are a few
things that need fixing, but nothing fatal.
{{{
-> throwOneError (mkPlainErrMsg noSrcSpan (ptext (sLit "No module
speficied for import")))
}}}
typo in the error message, and perhaps the message should say something
like "parse error in import declaration"?
{{{
+ -- 'ic_toplev_scope', 'ic_exports'
and 'ic_imports'
}}}
did that sneak in by mistake? I don't see `ic_imports` anywhere
{{{
+getImportDecl :: GhcMonad m => String -> m (ImportDecl RdrName)
+getImportDecl expr = withSession $ \hsc_env -> hscImport hsc_env
("import"++expr)
}}}
Did you really want `"import"++expr`, with no space between? I'd drop the
`"import"++` bit entirely, I think, and call the function
`parseImportDecl` (we already have `parseName`, which is similar).
{{{
- | ["import", mod] <- words stmt = keepGoing' setContext ('+':mod)
+ | ('i':'m':'p':'o':'r':'t':mod) <- stmt = keepGoing' (importContext
True) mod
}}}
check for a space after "import", otherwise you'll catch "imported" etc.
What happens if the user imports the same module twice, with different
import lists? They should accumulate, as in a source file, right? Does
it work that way? What happens if you import a module multiple times with
"import", and then say ":m -M"?
In `setContext` and `remembered_ctx` it feels to me like an import decl
should be a different kind of `CtxtCmd`, rather than dealing with them
separately at a higher level. I'm not sure about the interactions of
having multiple `:m` and `import` commands here, it would be simpler if
they were all dealt with together in `playCtxtCmd`. I realise this means
changing the types a bit more radically, though.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2362#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs