The Future of Haskell discussion at the Haskell Workshop

Ganesh Sittampalam ganesh@earth.li
Wed, 10 Sep 2003 11:23:27 +0100


On Wed, 10 Sep 2003 10:26:04 +0100, Robert Ennals
<Robert.Ennals@cl.cam.ac.uk> wrote:

>class Wibble a where
>    wibble :: a -> Int
>    wobble :: a -> String
>    set_wibble :: Int -> a -> a
>    set_wobble :: String -> a -> a
>
>
>data Foo = Foo {wibble :: Int, wobble :: String}
>	deriving Wibble
>
>
>The Wibble class defines selector and updater functions for fields called 
>wibble and wobble.
>
>When I define the datatype Foo, I give it fields called wibble and wobble, 
>which will define the functions in Wibble. If I say "deriving Wibble" then the 
>type system acknowledges that these functions are implementing the class 
>Wibble. If I had not derived Wibble then there would have been a name clash.

What would you do if Wibble had more functions than just those 4? You'd need
somewhere to put the implementations of the other functions for Foo.

Ganesh