[Haskell-cafe] Top Level etc.

Keean Schupke k.schupke at imperial.ac.uk
Wed Jan 19 08:31:48 EST 2005

I may have got this wrong, but I think you can do named instances 
without any extensions,
by using datatypes and fundeps:

data Instance0
data Instance1

instance0 :: Instance0
instance0 = undefined

instance1 :: Instance1
instance1 = undefined

class Named a b | a -> b
    test :: a -> b -> b
instance Named Instance0 Int
    test _ a = a + a
instance Named Instance1 Float
    test _ a = a * a

test instance0 1
test instance1 1.5


Benjamin Franksen wrote:

>You will probably find this paper interesting: Wolfram Kahl and Jan 
>Scheffczyk: "Named Instances for Haskell Type Classes", 

More information about the Haskell-Cafe mailing list