diff --git a/concepts/Abstract_data_type/Point.hs b/concepts/Abstract_data_type/Point.hs new file mode 100644 index 000000000..4b6fe8c99 --- /dev/null +++ b/concepts/Abstract_data_type/Point.hs @@ -0,0 +1,12 @@ +module Point( + Point, -- constructor is NOT exported + mkPoint, + getX, + getY +) where + +data Point = Point { getX :: Int, getY :: Int } + deriving (Eq, Show, Read) + +mkPoint :: Int -> Int -> Point +mkPoint = Point diff --git a/concepts/Abstract_data_type/PointProperties.hs b/concepts/Abstract_data_type/PointProperties.hs new file mode 100644 index 000000000..b823d1d48 --- /dev/null +++ b/concepts/Abstract_data_type/PointProperties.hs @@ -0,0 +1,8 @@ +import Point +import Test.QuickCheck + +prop_getX :: Int -> Int -> Bool +prop_getX x y = getX (mkPoint x y) == x + +prop_getY :: Int -> Int -> Bool +prop_getY x y = getY (mkPoint x y) == y