Functional programming in Python

Tom Pledger Tom.Pledger@peace.com
Mon, 28 May 2001 16:53:43 +1200


S. Alexander Jacobson writes:
 | On Fri, 25 May 2001, Zhanyong Wan wrote:
 | > As you explained, the parse of an expression depends the types of the
 | > sub-expressions, which imo is BAD.  Just consider type inference...

Also, we can no longer take a divide-and-conquer approach to reading
code, since the syntax may depend on the types of imports.

 | Ok, your complaint is that f a b c=a b c could have type
 | (a->b->c)->a->b->c or type (b->c)->(a->b)->a->c depending on the arguments
 | passed e.g. (f head (map +2) [3]) has different type from (f add 2 3).
 | 
 | Admittedly, this is different from how haskell type checks now.  I guess
 | the question is whether it is impossible to type check or whether it just
 | requires modification to the type checking algorithm.  Does anyone know?

Here's a troublesome example.

    module M(trouble) where

    f, g :: (a -> b) -> a -> b
    f = undefined
    g = undefined

    trouble = (.) f g

    -- ((.) f) g :: (a -> b) -> a -> b
    -- (.) (f g) :: (a -> b -> c) -> a -> b -> c

<Villainous cackle>

Regards,
Tom