Is there a way to specify the package name for a module for the :browse
, :load
or :module
commands in ghci (version 6.12.1) ?
Some module names are ambiguous:
Prelude> :module Control.Monad.Cont <no location info>: Ambiguous module name `Control.Monad.Cont': it was found in multiple packages: mtl-1.1.0.2 monads-fd-0.1.0.2
Is setting the -hide-package
option the only thing I can do to avoid the ambiguity?
The syntax for importing modules in a Haskell script is import <module name>. This must be done before defining any functions, so imports are usually done at the top of the file. One script can, of course, import several modules. Just put each import statement into a separate line.
Simply type a let followed by a newline: let ⏎. Then fac 0 = 1 ⏎. Then fac n = n * fac (n-1) ⏎ ⏎ and you're done!
If you don't need a fully partitioned GHC environment and are happy with the installed versions on DICE, cabal might be the simplest way to install the Haskell packages you require. By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.
Open a command window and navigate to the directory where you want to keep your Haskell source files. Run Haskell by typing ghci or ghci MyFile. hs. (The "i" in "GHCi" stands for "interactive", as opposed to compiling and producing an executable file.)
As far as I know, yes. But it doesn't have to be a big deal, you can do this inside ghci:
Prelude Data.List> :set -hide-package mtl package flags have changed, resetting and loading new packages... Prelude> import Control.Monad.Cont Prelude Control.Monad.Cont>
There was also a line-item on GHC-7 change log that made me think package imports would work on the command line, but it doesn't seem to yet (see below). The change comment said something like "full import syntax supported in GHCi", which must exclude extensions I suppose.
$ ghci-7.0.0.20100924 -XPackageImports GHCi, version 7.0.0.20100924: http://www.haskell.org/ghc/ :? for help ... Prelude Data.List> import "mtl" Control.Monad.Cont <no location info>: Ambiguous module name `Control.Monad.Cont': it was found in multiple packages: mtl-1.1.1.0 monads-fd-0.1.0.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With