Logo

Programming-Idioms

History of Idiom 5 > diff from v15 to v16

Edit summary for version 16 by :

Version 15

2015-09-02, 15:30:52

Version 16

2015-09-03, 11:26:43

Idiom #5 Create a 2D Point data structure

Declare a container type for two floating-point numbers x and y

Idiom #5 Create a 2D Point data structure

Declare a container type for two floating-point numbers x and y

Code
data Point = Point
  { x :: Double
  , y :: Double
  } deriving (Eq,Ord,Show,Read)
Comments bubble
This version contains a deriving statement at the end which automatically writes the equality, ordering, and to and from string functions for this type.