Opened 13 years ago

Closed 5 years ago

#1388 closed feature request (fixed)

Newbie help features

Reported by: guest Owned by:
Priority: low Milestone:
Component: GHCi Version: 6.6.1
Keywords: Cc: hvr, bgamari
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #4929, #7253, #9177 Differential Rev(s):
Wiki Page:

Description

Often a newbie comes to #haskell and asks why something doesn't work in ghci. There are at least two cases:

"why doesn't type Bar = (Char, Int) work"?

and

"why doesn't f = 1 work?" (that is function definitions)

It wouldn't be much work to recognize these cases and then give the user some hints on putting those definitions into a file, etc.

Another case where error messages can be improved is the following:

type Foo = (char, int) -- the intention is clear, but the error message might not be clear to a new user. Suggestion: when the parsed type variables are the same modulo case to an existing core type(Int, Bool, Array, etc) and Foo doesn't take those type parameters, tell the user he needs to use proper casing.

Change History (9)

comment:1 Changed 13 years ago by igloo

Milestone: 6.8

Good ideas!

comment:2 Changed 12 years ago by igloo

Milestone: 6.8 branch_|_

comment:3 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:4 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:5 Changed 10 years ago by simonmar

difficulty: Easy (1 hr)Easy (less than 1 hour)

comment:6 Changed 6 years ago by nomeata

Cc: hvr added
Type of failure: None/Unknown

type Bar = (Char, Int) works now in GHCi.

f = 1 doesn’t, but given that GHCi supports all(?) other toplevel declarations by now, I wonder why. I could even print something helpful like

> f = 1
Defined: f :: Num a => a

or less verbose

> f = 1
f :: Num a => a

so that the user knows what’s going on. Or simply treat it exactly like let f = 1.

comment:7 Changed 6 years ago by nomeata

Split the last suggestion in the original ticket to #9177

comment:8 Changed 5 years ago by thomie

Cc: bgamari added

Support for top-level declarations was added in #4929.

With 1ff7f09b3abedb2a6daf384b55ad3d0134f0d174, f = 1 now prints:

+    parse error on input ‘=’
+    Perhaps you need a 'let' in a 'do' block?
+    e.g. 'let x = 5' instead of 'x = 5'

comment:9 in reply to:  6 Changed 5 years ago by thomie

Resolution: fixed
Status: newclosed

"why doesn't f = 1 work?" (that is function definitions)

This is the only part remaining for this ticket, and already tracked as #7253.

Note: See TracTickets for help on using tickets.