Typing system vs. Java

Michael Abbott michael at rcp.co.uk
Tue Jul 31 11:56:54 EDT 2001


<brueckd at tbye.com> wrote in news:mailman.996590461.27817.python-
list at python.org:

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

Yes, I think this is the price you have to pay if you want this kind of 
type safety.

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

I would like the option of this kind of safety net, particularly after I've 
finished designing things in detail.  In particular, working out the types 
in detail can in itself be a helpful design tool.





More information about the Python-list mailing list