Skip to content

Commit

Permalink
ADT explained proper
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaemmel committed May 21, 2015
1 parent b1e3537 commit 3f6e56d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 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
8 changes: 8 additions & 0 deletions 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

0 comments on commit 3f6e56d

Please sign in to comment.