    {-# LANGUAGE NamedFieldPuns #-}
    {-# LANGUAGE RecordWildCards #-}

    module Records where

    data Point = Point
        { Point -> Int
    x :: !Int
        , Point -> Int
    y :: !Int
        }

    point :: Int -> Int -> Point
    point :: Int -> Int -> Point
    point x :: Int
    x y :: Int
    y = $WPoint :: Int -> Int -> Point
    Point { x :: Int
    x = Int
    x, y :: Int
    y = Int
    y }

    lengthSqr :: Point -> Int
    lengthSqr :: Point -> Int
    lengthSqr (Point { x :: Point -> Int
    x = Int
    x, y :: Point -> Int
    y = Int
    y }) = Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    y Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    y

    lengthSqr' :: Point -> Int
    lengthSqr' :: Point -> Int
    lengthSqr' (Point { Int
    x :: Int
    x :: Point -> Int
    x, Int
    y :: Int
    y :: Point -> Int
    y }) = Int
    y Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    y Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Int
    x

    translateX, translateY :: Point -> Int -> Point
    translateX :: Point -> Int -> Point
    translateX p :: Point
    p d :: Int
    d = Point
    p { x :: Int
    x = Point -> Int
    x Point
    p Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    d }
    translateY :: Point -> Int -> Point
    translateY p :: Point
    p d :: Int
    d = Point
    p { y :: Int
    y = Point -> Int
    y Point
    p Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    d }

    translate :: Int -> Int -> Point -> Point
    translate :: Int -> Int -> Point -> Point
    translate x :: Int
    x y :: Int
    y p :: Point
    p =
        Point -> Point
    aux Point
    p
      where
        (dx :: Int
    dx, dy :: Int
    dy) = (Int
    x, Int
    y)
        aux :: Point -> Point
    aux Point{..} = Point
    p { x :: Int
    x = Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    dx, y :: Int
    y = Int
    y Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    dy }