Opened 14 years ago

Closed 10 years ago

Last modified 8 years ago

#125 closed feature request (fixed)

GHCi Usability

Reported by: nobody Owned by: nobody
Priority: lowest Milestone: 6.8.1
Component: None Version: None
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

About GHCi

I find that Haskell interpreter is rather difficult to use:
1."f=3" is a legal statement in Haskell, i.e. define "f" as 
   constant function, but a parse error occurs.
  "let f=3" is illegal, "let" and "in" are used together, but
   it works in GHCi. 
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.
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 

Change History (7)

comment:1 Changed 14 years ago by wthaller

Summary: GHCi ProblemsGHCi Usability
Logged In: YES 

Moved from Bugs to Feature Requests.
Mr. Nobody obviously expected to be able to...
*) use "import" in GHCi. It might be a bit more obvious than
:l and :m.
*) Write things like 'f = 3' instead of 'let f = 3'. Again,
it would be just slightly more obvious to beginners.

Low priority because people should Read The Fine Manual anyway.

And while we're at it, what about
*) data type declarations
*) foreign import
at the GHCi prompt?

comment:2 Changed 14 years ago by haeleth

Logged In: YES 

Regarding 1, this is the case because the GHCi prompt 
behaves as a `do' clause in the IO monad.  This can be 
demonstrated by the fact that the syntax for opening a file is 
`hfile <- openFile "foo.txt" ReadMode', rather than 
`openFile "foo.txt" ReadMode >>= \hfile -> do'.  Hence

(a) you cannot type `import' because this is only valid at the 
start of a module;

(b) you must type `let x = n' rather than `x = n', and `in' is 
not required, because this is the `do' syntax.

I'm not sure if this is made explicit in the manual, but it might 
be an idea to make it so if it isn't.

comment:3 Changed 10 years ago by igloo

Architecture: Unknown
Description: modified (diff)
difficulty: Unknown
Milestone: 6.8
Operating System: Unknown

comment:4 Changed 10 years ago by simonmar

Resolution: Nonefixed
Status: assignedclosed

I made it so you can say import M at the prompt; it has the same effect as :module +M. I think we can close this bug now.

comment:5 Changed 9 years ago by igloo

Milestone: 6.8 branch6.8.1

comment:6 Changed 8 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:7 Changed 8 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.