
17 Dec
2007
17 Dec
'07
6:10 a.m.
"Nicholls, Mark"
After many years of OOP though my brain is wired up to construct software in that ?pattern??.a problem for me at the moment is I cannot see how to construct programs in an OO style in Haskell?.I know this is probably not the way to approach it?but I feel I need to master the syntax before the paradigm.
Mostly, you'd use an algebraic data type. I.e. data Shape = Square Int | Rectangle Int Int | Circle Int area :: Shape -> Int area (Square x) = x^2 area (Rectangle x y) = x * y area (Circle r) = pi*r^2 -k -- If I haven't seen further, it is by standing in the footprints of giants