January 30th, 2014, 03:57 AM

[Haskell] Function to create a circle
hi,
attempting to get some help here
Code:
type Figure a = Pos > a
type Pos = (Double, Double)  (x, y)
now i need to create a circle which has type::
Double > Figure Bool
so written out Double > Pos > Bool
and or a position (x,y) i need to check if it falls into the circle or not
so:
circle gets an argument of double which is the radius
circe r
and a position for the Figure
circle r (x,y)
the formula to create a circle is \r > pi*r^2
so i use foldr(\r > pi*r^2)
and then i need to see if (x,y) falls into the circle
for this i use elem()[]
so i get
circle r = elem (x,y) (foldr(\r > pi*r^2))
but this gives me :
Code:
Type error in application
*** Expression : (x,y) `elem` foldr (\r > pi * r ^ 2)
*** Term : foldr (\r > pi * r ^ 2)
*** Type : b > [b > b] > b
*** Does not match : [a]
anyone who has insight ?