| -----Original Message-----
| From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John
| Hughes
| Sent: 10 January 2005 09:16
| To: [email protected]
| Subject: [Haskell-cafe] Re: Some random newbie questions
| 
| I seriously considered switching frlom Hugs to GHC for my introductory
| programming class this year, but in the end stayed with Hugs because
of
| a single feature.
| 
| I'm teaching beginning programmers, and for them at least, there is an
| overwhelming volume of names to learn -- "what's that function?" is a
| question they ask themselves often, as is "what's that type?". I teach
| them that, whenever they see a name they don't recognise, they can
find
| out more about it using the :i command. This is a simple trick to
learn,
| that helps them understand points they've missed and catches
| misapprehensions.
| 
| My students also see type classes very early. I'll bet yours will too.
| Even if one is very careful to restrict the examples in lectures so as
| to avoid them (which is a bind), as soon as students try out Hugs for
| themselves, they will make mistakes that generate error messages
| referring to type classes. No problem: the question "what's that
class?"
| can ALSO be answered by :i.
| 
| Now, at the beginning students have only a very rudimentary
| understanding of classes. A class is a collection of types to them,
| nothing more. In particular, the class definition itself is of little
| use to them, since it often contains a very subtly chosen collection
of
| methods (just type :i Show, for example, which students do very
early).
| What IS useful, right from the beginning, is the list of instances.
What
| are Num types? Oh, integers and reals.  What are Show types? Oh,
pretty
| much everything. Particularly when debugging "missing instance"
errors,
| this is just the information you need.
| 
| Unfortunately, while Hugs prints the list of instances of a class in
| response to :i, GHCi does not. It only prints the class definition --
| which, for my students, contains no useful information. For that
reason
| alone, I stuck with Hugs last year.

| How about changing the behaviour of :i, Simon, so I can use GHCi
| throughout next year?

Done, some while ago.  You want GHC 6.4!  See below

Simon

Prelude> :i Show
class Show a where
  showsPrec :: Int -> a -> String -> String
  show :: a -> String
  showList :: [a] -> String -> String
-- Imported from `GHC.Show'
instance Show IOMode    -- Imported from `GHC.IOBase'
instance Show IOException       -- Imported from `GHC.IOBase'
instance Show IOErrorType       -- Imported from `GHC.IOBase'
instance Show HandleType        -- Imported from `GHC.IOBase'
instance Show Handle    -- Imported from `GHC.IOBase'
instance Show ExitCode  -- Imported from `GHC.IOBase'
instance Show Exception         -- Imported from `GHC.IOBase'
instance Show BufferMode        -- Imported from `GHC.IOBase'
instance Show AsyncException    -- Imported from `GHC.IOBase'
instance Show ArrayException    -- Imported from `GHC.IOBase'
instance Show ArithException    -- Imported from `GHC.IOBase'
instance Show SeekMode  -- Imported from `GHC.Handle'
instance Show HandlePosn        -- Imported from `GHC.Handle'
instance Show CWchar    -- Imported from `Foreign.C.Types'
instance Show CUShort   -- Imported from `Foreign.C.Types'
instance Show CULong    -- Imported from `Foreign.C.Types'
instance Show CULLong   -- Imported from `Foreign.C.Types'
instance Show CUInt     -- Imported from `Foreign.C.Types'
instance Show CUChar    -- Imported from `Foreign.C.Types'
instance Show CTime     -- Imported from `Foreign.C.Types'
instance Show CSize     -- Imported from `Foreign.C.Types'
instance Show CSigAtomic        -- Imported from `Foreign.C.Types'
instance Show CShort    -- Imported from `Foreign.C.Types'
instance Show CSChar    -- Imported from `Foreign.C.Types'
instance Show CPtrdiff  -- Imported from `Foreign.C.Types'
instance Show CLong     -- Imported from `Foreign.C.Types'
instance Show CLLong    -- Imported from `Foreign.C.Types'
instance Show CLDouble  -- Imported from `Foreign.C.Types'
instance Show CInt      -- Imported from `Foreign.C.Types'
instance Show CFloat    -- Imported from `Foreign.C.Types'
instance Show CDouble   -- Imported from `Foreign.C.Types'
instance Show CClock    -- Imported from `Foreign.C.Types'
instance Show CChar     -- Imported from `Foreign.C.Types'
instance Show (GHC.Ptr.Ptr a)   -- Imported from `Foreign.Ptr'
instance Show (GHC.Ptr.FunPtr a)        -- Imported from `Foreign.Ptr'
instance Show Float     -- Imported from `GHC.Float'
instance Show Double    -- Imported from `GHC.Float'
instance Show Int8      -- Imported from `GHC.Int'
instance Show Int64     -- Imported from `GHC.Int'
instance Show Int32     -- Imported from `GHC.Int'
instance Show Int16     -- Imported from `GHC.Int'
instance Show Word8     -- Imported from `GHC.Word'
instance Show Word64    -- Imported from `GHC.Word'
instance Show Word32    -- Imported from `GHC.Word'
instance Show Word16    -- Imported from `GHC.Word'
instance Show Word      -- Imported from `GHC.Word'
instance Show [a]       -- Imported from `GHC.Show'
instance Show (a, b, c, d, e)   -- Imported from `GHC.Show'
instance Show (a, b, c, d)      -- Imported from `GHC.Show'
instance Show (a, b, c)         -- Imported from `GHC.Show'
instance Show (a, b)    -- Imported from `GHC.Show'
instance Show ()        -- Imported from `GHC.Show'
instance Show Ordering  -- Imported from `GHC.Show'
instance Show (Maybe a)         -- Imported from `GHC.Show'
instance Show Int       -- Imported from `GHC.Show'
instance Show (Either a b)      -- Imported from `GHC.Show'
instance Show Char      -- Imported from `GHC.Show'
instance Show Bool      -- Imported from `GHC.Show'
Prelude>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to