> 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 _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell