module Week06 where import Debug.Trace(trace) type Point = (Xordinate,Yordinate) type Xordinate = Float type Yordinate = Float distance :: Point -> Point -> Float distance (x1,y1) (x2,y2) = sqrt (xDifference^2 + yDifference^2) where xDifference = x1 - x2 yDifference = y1 - y2 -- type Color = (Int,Int,Int) data Color = Red | Green | Black | Yellow | White | Orange | Puce deriving (Eq, Show, Ord, Enum) {- data Bool = True | False deriving (Show,Eq,Enum,Ord) -} myLength' :: [a] -> Int myLength' [] = 0 myLength' (_:rest) = 1 + (myLength' rest) myLength :: (Eq a) => [a] -> Int myLength list | list == [] = 0 | otherwise = 1 + (myLength rest) where rest = tail list type Name = String fave :: Name -> Color fave "julia" = Red fave "david" = Puce fave "angel" = Black data Shape = Square Float | Circle Float | Triangle Float Float Float deriving (Eq, Show) perimeter :: Shape -> Float perimeter (Square side) = 4 * side perimeter (Triangle a b c) = Debug.Trace.trace "its a triangle!" (a + b + c) perimeter (Circle radius) = 2 * pi * radius