Yes, the OOHaskell paper blew my mind too, but I still only understood half of it when reading it for the second time (especially the mfix thing was scary :-) Not giving up though ;-) But I wander if the error messages you would get from GHC make it easy to see what is going wrong. It would be great if a library author could somehow customize error reporting too, although I have no idea if that is possible.
On Tue, Sep 29, 2009 at 10:03 AM, Alp Mestan <a...@mestan.fr> wrote: > I had never seen this work, it's just awesome ! > And it only needs few Haskell extensions. > > Is this work deeply documented somewhere except in research papers ? If > not, it could be worth doing, IMO. > > > On Tue, Sep 29, 2009 at 9:37 AM, <o...@okmij.org> wrote: > >> >> Alp Mestan wrote: >> > Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. >> > >> > *# let f myobj = myobj#foo "Hi !";; >> > val f : < foo : string -> 'a; .. > -> 'a = <fun>* >> >> And Haskell has that too: >> >> > -- This is how we define labels. >> > data Field1 deriving Typeable; field1 = proxy::Proxy Field1 >> > >> > -- This is how record selection looks like. >> > foo f = f # field1 >> >> The inferred type of foo is >> >> *OCamlTutorial> :t foo >> foo :: (HasField (Proxy Field1) r v) => r -> v >> >> It doesn't seem too different from the OCaml's type; the type variable >> r acts as a row type. >> >> The quoted example is the first from many others described in >> http://darcs.haskell.org/OOHaskell/OCamlTutorial.hs >> >> The file quotes at length OCaml's Object tutorial and then >> demonstrates how the OCaml code can be written in Haskell. When it >> comes to objects, structural subtyping, width and depth subtyping, >> etc., Haskell does not seem to miss match compared to OCaml. In >> contrast, Haskell has a few advantages when it comes to coercions >> (one does not have to specify the type to coerce to, as Haskell can >> figure that out). The other files in that directory give many more >> example of encoding C++, Eiffel, OCaml patterns. >> >> > > > -- > Alp Mestan > http://blog.mestan.fr/ > http://alp.developpez.com/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe