I've linked to an ugly attempt to emulate subclasses in Haskell, and I'm wondering if anyone has done what I have perhaps in a cleaner way.Firstly, the code is here: http://ideone.com/znHfSGTo explain what I've done, I first thought that a "method" basically takes some "input" (which I've called "i"), an object (which I've called "c" for class) and returns some output "o" and a potentially modified object "c". I've captured this behaviour in the badly named class "C".I've then made a class "User", with methods "getFirstName" and "putFirstName" and defined them appropriately.Furthermore, I've then made a data type "Age", and then "ExtendedUser" which combines "User" with "Age".At this point, I can still call "getFirstName" and "putFirstName" on "ExtendedUser", as would be hoped.I also defined "getAge", which naturally works on ExtendedUser.Furthermore, I can override "getFirstName" on "ExtendedUser", which I have done to instead return a capitalised version.Is what I've done of any practical use? And has someone done it better than me?
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe