[Haskell] Object-Orientation and Haskell
Ralf Lammel
ralfla at microsoft.com
Sat Sep 24 04:29:41 EDT 2005
> Define a type A such that for any type B you can define
>
> up :: B -> A
> down :: A -> Maybe B
>
> such that
>
> down . up = Just
>
> You can do this quite easily in Java or C++, mutatis mutandis. You
can't
> do this in Haskell, I don't think. You can't actually do this in
> O'Haskell either, it seems the O' essentially amounts to syntactic
sugar.
You can't even do this in OCaml.
However, in OOHaskell you can.
>From the TOC of the OOHaskell paper
http://homepages.cwi.nl/~ralf/OOHaskell/
5.4 Casts based on dynamics 50
5.5 Casts based on unions 51
The second technique may add something to this discussion here.
We use a sort of intersection-type encoding (also reminiscent of TICs).
Thanks,
Ralf
More information about the Haskell
mailing list