diff options
Diffstat (limited to 'hypsrc-test/src/Records.hs')
-rw-r--r-- | hypsrc-test/src/Records.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hypsrc-test/src/Records.hs b/hypsrc-test/src/Records.hs index 4118e296..40a01121 100644 --- a/hypsrc-test/src/Records.hs +++ b/hypsrc-test/src/Records.hs @@ -1,4 +1,6 @@ {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} + module Records where @@ -23,3 +25,10 @@ lengthSqr' (Point { x, y }) = y * y + x * x translateX, translateY :: Point -> Int -> Point translateX p d = p { x = x p + d } translateY p d = p { y = y p + d } + +translate :: Int -> Int -> Point -> Point +translate x y p = + aux p + where + (dx, dy) = (x, y) + aux Point{..} = p { x = x + dx, y = y + dy } |