GHCi doesn't directly let you enter Haskell statements. As you say,
you can write "let f = 3 in <expr>", and "let f = ..." is roughly a
shorthand for "let f = ... in <rest of program>".
> 2. if I happen to print out an infinite list, I don't know how to
> interrupt it, when press Ctrl+C, GHCi just quit.
Huh. Ctrl-C works for me (Linux/ia32). Judging from your next question,
I assume you're on win32, which I know nothing about.
> 3. I can't use "import" to import modules. There are many sub
> directories in the imports directory, but I don't know how to import
> libraries in concurrent, win32, util, lang and objectio. When I
> installed GraghicsLib, I can't use it in GHC, for GHCi can't find the
> SOEGraghics and Concurrent modules.
No, you can't use import. :load will work, and it should chase imports
in existing packages. GHCi is more oriented to trying out expressions
defined by existing files, rather than entering code.
ghci -package concurrent should let you access the Concurrent module, and
so forth.
--
Aaron Denney
-><-
Why not, the Python interpreter is a good example.
> you can write "let f = 3 in <expr>", and "let f = ..." is roughly a
> shorthand for "let f = ... in <rest of program>".
>
> > 2. if I happen to print out an infinite list, I don't know how to
> > interrupt it, when press Ctrl+C, GHCi just quit.
>
> Huh. Ctrl-C works for me (Linux/ia32). Judging from your next question,
> I assume you're on win32, which I know nothing about.
Yes, I'm using windowsXP, but Hugs doesn't have this bug.
>
> > 3. I can't use "import" to import modules. There are many sub
> > directories in the imports directory, but I don't know how to import
> > libraries in concurrent, win32, util, lang and objectio. When I
> > installed GraghicsLib, I can't use it in GHC, for GHCi can't find the
> > SOEGraghics and Concurrent modules.
>
> No, you can't use import. :load will work, and it should chase imports
> in existing packages. GHCi is more oriented to trying out expressions
> defined by existing files, rather than entering code.
>
> ghci -package concurrent should let you access the Concurrent module, and
> so forth.
if I want to use both Concurrent and Win32, I have to say:
ghci -package concurrent -package win32
when ghci is already opened, how to load package
and how can I use ghc to compile file using these packages?
> wno...@ugcs.caltech.edu (Aaron Denney) wrote in message news:<slrnb7l2ql...@hork.ugcs.caltech.edu>...
>> On 20 Mar 2003 19:23:05 -0800, Liu Junfeng <ru...@163.com> wrote:
>>> I find that Haskell interpreter is rather difficult to use:
>>> 1."f=3" is a legal statement in Haskell, i.e. define "f" as a
>>> constant function, but a parse error occurs. "let f=3" is illegal,
>>> "let" and "in" are used together, but it works in GHCi.
>> GHCi doesn't directly let you enter Haskell statements.
> Why not,
I've no idea if this is the reason, but I like to think about GHCi as
running the IO monad. So you can enter things like
x <- readFile "foo"
and actually have x be the contents of that file. Frankly, I don't
see the problem of using 'let' to assign values.
> the Python interpreter is a good example.
Do you actually use the interpreter to enter real programs? I always
use an editor for that, and I find GHCi at least as comfortable as the
Python interactive. (But I'm of course not a Python expert)
(Perhaps it'd be possible to have a (user defined?) command to edit a
function, which could, for instance, bring up an emacs window (using
gnuclient) with the correct file, narrowed to the appropriate
function?)
-kzm
--
If I haven't seen further, it is by standing in the footprints of giants
> Why not, the Python interpreter is a good example.
Haskell and Pyhton are quite different languages.
E.g., in Haskell, the order of the definitions does not
is not significant.
>>>I find that Haskell interpreter is rather difficult to use:
>>>1."f=3" is a legal statement in Haskell, i.e. define "f" as a constant
>>>function, but a parse error occurs. "let f=3" is illegal, "let" and
>>>"in" are used together, but it works in GHCi.
>>
>>GHCi doesn't directly let you enter Haskell statements.
>
> Why not, the Python interpreter is a good example.
>
>>you can write "let f = 3 in <expr>", and "let f = ..." is roughly a
>>shorthand for "let f = ... in <rest of program>".
Dont compare the incomparable. Python is a straightforward compiler/
interpreter, like Scheme. You write something, it gets evaluated and
the world continues, if that something was a definition, the actual
environment gets updated.
In languages with a stricter typing discipline, and "functional purity",
which perform more global program analysis the situation is more
delicate. CAML, when you enter a new definition augments the current
environment by a new instance. Haskell "should" read a whole program,
*all* definitions in any order. But GHCi is a hybrid, an incremental
monadic IO layer which invokes the compiler. The 'let' without 'in'
works because in a sense you are always within a 'do' block.
It provides the sequencing.
Unless I am telling rubbish, which happens on average 2.72 times per
month.
Jerzy Karczmarczuk
Since that's one of the 86.54% of made-up internet statistics, your
remaining quota for the month is 1.72 ;-)
Regards,
Joachim
--
This is not an official statement from my employer.
Exactly.
> when ghci is already opened, how to load package
:set -package <name>
> and how can I use ghc to compile file using these packages?
ghc -package <name> ... file.hs
http://haskell.cs.yale.edu/ghc/docs/5.04.3/html/users_guide/x1059.html
.