"Cagdas Ozgenc" <[EMAIL PROTECTED]> writes:

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

the goal of type class is to allow overloading of function, so for example 
id x = x     is not subject to overloading => no use to put it in a type class.

> 
> 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.

yes, that's right that map and elem could be put in a type class, but that's hard and 
require
more advanced feature of haskell (here you use constructor class but you need more : 
multi-parameter class, ....) 
see http://www.cse.ogi.edu/~mpj/fds.html.


> 
> Thanks
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 

-- 
          Yoann  Padioleau,  INSA de Rennes, France,
Opinions expressed here are only mine. Je n'�cris qu'� titre personnel.
**____   Get Free. Be Smart.  Simply use Linux and Free Software.   ____**

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to