From 354d3296371099bad2729cf7b5445d23a107c6c5 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Tue, 30 Jun 2015 20:18:42 +0200 Subject: Add test case for record expressions and patterns hyperlinking. --- hypsrc-test/src/Records.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 hypsrc-test/src/Records.hs 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 } -- cgit v1.2.3