Typing system vs. Java

brueckd at tbye.com brueckd at tbye.com
Tue Jul 31 16:08:18 CEST 2001


On Tue, 31 Jul 2001, Michael Abbott wrote:

> >    def f(zs): return reduce( lambda x, y: x + y, zs )
> >
>     	f :: Num a => [a] -> a
>
>     	class SemiGroup a where
>     	    (+) :: a -> a -> a
>
>     	f :: SemiGroup a => [a] -> a
>
>     	reduce :: (a -> a -> a) -> [a] -> a
>
>     	(+) :: Num a => a -> a -> a

This goes back to my orignal point: when the language forces you to be so
explicit with the type it sometimes requires you to give it more
information than you really have, and so you have to stop and invent a
pigeonhole in which you can place this thing. I suppose that once you get
it right then it could provide a sort of safety net, but too often
"getting it right" is complex and error-prone (or maintenance-prone, if
your original definition was too restrictive and you need to go back and
modify it to be more broad).

-Dave





More information about the Python-list mailing list