Reputation: 950
Does it is possible to use the equivalent of "import qualified" in GHCI with our OWN module? Something like :m + qualified Data.List
which of course doesn't work.
Thanks.
Upvotes: 10
Views: 4406
Reputation: 36612
I don't know of a pretty way to do what you want, but you could fake it with something like this:
:load My/Module.hs
to load your module.:module - My.Module
to bring it out of scope.import qualified My.Module as MM
to bring it into scope qualified.Every module that GHCi knows about is automatically available fully qualified, so after step 2, My.Module.value
will work fine. Step 3 is only necessary if you want to use a shorter prefix.
If you want to load multiple files at once, :load
can do that too;
:load My/Module1.hs My/Module2.hs ... My/ModuleN.hs
will work fine. It will put you in the scope of *My.Module1
, and then My.Module2
… My.ModuleN
will all be available fully qualified as mentioned above.
For more about GHCi, you can always check the GHC User's Guide, Ch. 2: "Using GHCi"; particularly relevant sections are §2.2, "Loading source files" and §2.4.5, "What's really in scope at the prompt?".
Upvotes: 16
Reputation: 5001
Just type import qualified Data.Text
or import qualified Data.Text as T
inside ghci, just as you would do inside your code.
Upvotes: 24