
On Wed, Nov 29, 2006 at 06:08:14PM +0000, Malcolm Wallace wrote:
Unfortunately, I suspect that teaching is _the_ major use-case for defaulting. Imagine, day one, lesson one, a student types
Prelude> 1+2
into Hugs, and gets the response
Unresolved overloading: Num a
Huh? This is lesson one, and you already need to tell students about type classes and overloading, before you have even covered simple expressions fully? I am certain this is the reason why defaulting was introduced.
Following a suggestion of Ralf Hinze, GHCi and Hugs already perform more defaulting on interpreted expressions than on definitions in modules (where they follow Haskell 98). Thus "reverse []" just works, instead of provoking ERROR: Cannot find "show" function for: *** expression : reverse [] *** of type : [a] See http://www.haskell.org/ghc/docs/latest/html/users_guide/ch03s04.html#extende... So if defaulting were removed from the language it could still be done at the interpreter prompt.