is this not a better way ? data structure

Hello, In the book there is a example of this data-structure. data Shape = Circle float float | Rectangle float float Now I have to change it to add a center point. But I wonder if this is not a better way to describe it Data Schape = Circle Radius | Rectangle Width Height Type Radius = Float type Width = Float type Height = Float Roelof

I feel the latter example serves only documentation purposes. Maybe
describe what those floats are in the former example and you can ignore the
extra type aliases entirely.
Introducing a new concern for your module/application when it appears only
once might just add extra complexity.
Of course, as the codebase grows and this datatype evolves, you'll probably
want to go that route, but until then, I think it's preemptively unecessery.
- nitrix
On Nov 7, 2015 4:56 PM, "Roelof Wobben"
Hello,
In the book there is a example of this data-structure.
data Shape = Circle float float | Rectangle float float
Now I have to change it to add a center point.
But I wonder if this is not a better way to describe it
Data Schape = Circle Radius | Rectangle Width Height
Type Radius = Float type Width = Float type Height = Float
Roelof
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

As an aside, don't use ~Float~. Unless you have a specific reason to want a half-precision floating point type, you should use ~Double~.
participants (3)
-
Alex Belanger
-
Rein Henrichs
-
Roelof Wobben