Functional programming

Rustom Mody rustompmody at gmail.com
Tue Mar 4 01:20:51 EST 2014


On Tuesday, March 4, 2014 11:34:55 AM UTC+5:30, Chris Angelico wrote:
> On Tue, Mar 4, 2014 at 4:35 PM, Steven D'Aprano wrote:
> > I have not used Haskell enough to tell you whether you can specify
> > subtypes. I know that, at least for numeric (integer) types, venerable
> > old Pascal allows you to define subtypes based on integer ranges, so I'd
> > be surprised if you couldn't do the same thing in Haskell.
> > The flexibility of the type system -- its ability to create subtypes and
> > union types -- is independent of whether it is explicitly declared or
> > uses type inference.

> I'm not sure how you could have type inference with subtypes.

Short answer: You cant [Yeah Some folks dont like my short answers :-) ]

Long answer: See the links I posted above

Intermediate answer:
Types (for a modern FPL) are like math sets except that:
- set-membership is in general hard and in principle undecidable
- type-membership had better be decidable and preferably linear-time if its 
to be part of an implementation (and not a philosophical discussion over a cuppa
chai)
- Which means that...

> Static and dynamic typing both have their uses. But when I use static
> typing, I want to specify the types myself. I'm aware that's a matter
> of opinion, but I don't like the idea of the compiler rejecting code
> based on inferred types.

...Type inference is strictly (aka mathematically) syntax even though
in the implementation, the parsing phase and the type checking/inferencing phase
are sequenced

In short: An important flavor of the FP koolaid is the Damas-Milner
type-inferencing algorithm. Damas-Milner + Subtyping is the recipe for
a severe headache -- An important reason why FP and OOP are incompatible



More information about the Python-list mailing list