aboutsummaryrefslogtreecommitdiff
path: root/hypsrc-test
diff options
context:
space:
mode:
Diffstat (limited to 'hypsrc-test')
-rw-r--r--hypsrc-test/src/Records.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/hypsrc-test/src/Records.hs b/hypsrc-test/src/Records.hs
new file mode 100644
index 00000000..4118e296
--- /dev/null
+++ b/hypsrc-test/src/Records.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE NamedFieldPuns #-}
+
+module Records where
+
+
+data Point = Point
+ { x :: !Int
+ , y :: !Int
+ }
+
+
+point :: Int -> Int -> Point
+point x y = Point { x = x, y = y }
+
+
+lengthSqr :: Point -> Int
+lengthSqr (Point { x = x, y = y }) = x * x + y * y
+
+lengthSqr' :: Point -> Int
+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 }