seeking ideas for short lecture on type classes

Dylan Thurston dpt@math.harvard.edu
Mon, 27 Jan 2003 10:47:57 -0500


--4Ckj6UjgE2iN1+kY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jan 27, 2003 at 12:25:52PM +0200, Lauri Alanko wrote:
> On Mon, Jan 27, 2003 at 08:37:06PM +1100, Fergus Henderson wrote:
> > I agree.  The above characterization is highly misleading.  It would be
> > more accurate and informative to say that both Haskell and OO languages
> > dispatch on the dynamic type of a value.
>=20
> What is the "dynamic type of a value" in Haskell, apart from existentials
> and Dynamic? Ordinary type class dispatch is all done based on the types =
of
> variables, not their values. All the dispatching could even be done at
> compile time by specializing everything...

I don't think this is true, even without existential types.
Polymorphic recursion may involve building dictionaries at run time,
which certainly approaches dynamic dispatch.

(Polymorphic recursion is one of Chris Okasaki's favorite tricks.  It
involves definitions like

data Tree a =3D Leaf a | Node (Tree [a]) (Tree [a])

in which the variable 'a' is used recursively at a different type.)

Best,
	Dylan Thurston

--4Ckj6UjgE2iN1+kY
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+NVSsVeybfhaa3tcRAtQJAJ9bcana/1I5NcnflVfEhbg0Z2JwngCghPWC
uIkGIX0Y1Jjum+dqvJtgOso=
=1dsQ
-----END PGP SIGNATURE-----

--4Ckj6UjgE2iN1+kY--