Field Projections  < Overview  When data types are defined using
field names, we can use the projection operator (.) to select
the fields.  data Vector          = Vector { x :: Float; y ::
Float; }  main ()  = do   vec = Vector 3.0 4.0         putStrLn
$ show vec.x          -- prints '3.0'         putStrLn $ show
vec.y          -- prints '4.0'  Custom projections  We can also
define our own, custom projections and use (.) to select them. A
project definition is similar to Haskell style instance
definition in that it defines a set of functions associated with
a particular type (in this case, Vector). When we use (.), its
first argument is passed as the first argument to our projection
function - and so on.  project Vector where         magnitude ::
Vector -> Float         magnitude (Vector x y)           = sqrt
(x * x + y * y)          dot :: Vector -> Vector -> Float
dot (Vector x1 y1) (Vector x2 y2)          = x1 * x2 + y1 * y2
main ()  = do   ...         putStrLn $ show vec.magnitude