Are anonymous type classes the right model at all? (replying to Re: Are fundeps the right model at all?)

Johan Nordlander
Mon, 08 Jan 2001 15:42:16 -0800

Tom Pledger wrote:
> Marcin 'Qrczak' Kowalczyk writes:
>  [...]
>  > My new record scheme proposal does not provide such lightweight
>  > extensibility, but fields can be added and deleted in a controlled
>  > way if the right types and instances are made.
> Johan Nordlander must be on holiday or something, so I'll deputise for
> him.   :-)

No holiday in sight, I'm afraid :-)  I just managed to resist the 
temptation of throwing in another ad for O'Haskell.  But since my name
was brought up...

> O'Haskell also has add-a-field subtyping.  Here's the coloured point
> example (from
>    struct Point =
>       x,y :: Float
>    struct CPoint < Point =
>       color :: Color
> Regards,
> Tom

Notice though that O'Haskell lacks the ability delete fields, which I
think is what Marcin also proposes.  I've avoided such a feature in 
O'Haskell since it would make the principal type of an expression
sensitive to future type declarations.  For example, assuming we have

   f p = p.x ,

its principal type would be Point -> Float if only the type definitions
above are in scope, but OneDimPoint -> Float in another scope where some
type OneDimPoint is defined to be Point with field y deleted.

-- Johan