Existential Type Declarations in Hugs

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
3 May 2001 08:15:06 GMT


Thu, 3 May 2001 02:54:26 EDT, Critterrathman@aol.com <Critterrathman@aol.com> pisze:

>    class Shape a where
>       getx :: a -> Int
>       setx :: a -> Int -> a
> 
>    data ExistentialShape =
>       forall a. Shape a => MakeExistentialShape a
> 
>    instance Shape ExistentialShape where
>       getx (MakeExistentialShape a) = getx a
>       setx (MakeExistentialShape a) newx = setx a newx

Should be:
        setx (MakeExistentialShape a) newx = MakeExistentialShape (setx a newx)
The result of setx must have the same type as its first argument.

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK