44 lines
844 B
Plaintext
44 lines
844 B
Plaintext
type Point = Point x y
|
|
|
|
instance Show Point where
|
|
show (Point x y) = "Point " ++ (show x) ++ " " ++ (show y)
|
|
|
|
instance Name Point where
|
|
getField nm (Point x y)
|
|
| nm == "x" = x
|
|
| nm == "y" = y
|
|
| else = fail "Undefined name."
|
|
isField nm _ = nm == "x" || nm == "y"
|
|
|
|
pointX = flip Point 0
|
|
|
|
pointY = Point 0
|
|
|
|
pointEmpty = Point 0 0
|
|
|
|
type Circle = Circle x y z
|
|
|
|
instance Show Circle where
|
|
show (Circle x y z) =
|
|
"Circle " ++ (show x) ++ " " ++ (show y) ++ " " ++ (show z)
|
|
|
|
instance Name Circle where
|
|
getField nm (Circle x y z)
|
|
| nm == "x" = x
|
|
| nm == "y" = y
|
|
| nm == "z" = z
|
|
| else = fail "Undefined name."
|
|
isField nm _ = nm == "x" || nm == "y" || nm == "z"
|
|
|
|
circleXZ = flip Circle 0
|
|
|
|
circleX x = Circle x 0 0
|
|
|
|
circleYZ = Circle 0
|
|
|
|
circleY y = Circle 0 y 0
|
|
|
|
circleZ = Circle 0 0
|
|
|
|
circleEmpty = Circle 0 0 0
|