functions not in type classes

Cagdas Ozgenc co19@cornell.edu
Fri, 18 Jan 2002 10:06:30 +0200


Greetings.

Why does Haskell let you write functions that are not a part of type class?
For example instead of

elem :: Eq a => a -> [a] -> Bool
map :: (a -> b) -> [a] -> [b]

class Container a where
    elem :: Eq b => b -> a b -> Bool
    map :: (b -> c) -> a b -> a c

would define methods that can work on all containers, and create a
discipline to write more reusable and generic functions.

Thanks