[Haskell-cafe] Re: [Haskell] Typing in haskell and mathematics

Henning Thielemann lemming at henning-thielemann.de
Mon Jan 31 12:29:31 EST 2005

On Fri, 28 Jan 2005, Jacques Carette wrote:

> > > First, consider a syntax for other component-wise function application?  For example, it would be convenient to 
> > >have
> > > (f,g) @ (x,y)
> > > be (f x, g y).  In some languages [with dynamic typing], one can even do (f,g) (x,y) :-)
> > I am not sure what you mean, but you can define exactly that (except
> > for the @ sign which is special syntax already):
> > (f,g) `ap2` (x,y) = (f x, g y)
> [I should have looked harder for better syntax]
> I meant to
> a) overload application
> b) do it for all tuples at once
> Building all of Nat into the names of my functions does not appeal to me...

There was some similar discussion about allowing function application
notation for other objects than functions, e.g. FiniteMaps.  This would be
rather like treating polynomials like functions, a problem you pointed out
in my slides. I don't feel good about such implicit liftings. Haskell
already allows in many cases to factor out common work, but letting it do
that automatically creates a lot of new problems, you can't estimate
currently. I've worked with MatLab which does not distinguish between
scalar values, single element vectors and 1x1 matrices - it's just awful,
because earlier or later you start writing functions to workaround MatLabs
automatisms just to get a consistent behaviour for 1 dimensional vectors
and 1x1 matrices.

> Expressions with free variables as first-class values is indeed an
> obvious 'next' thing to want, if one is to parallel mathematics.

Like the expressions which D and Lim and Plot in Mathematica require as
arguments? I think they are responsable for all the mess in Mathematica
and Maple.

> > This is pretty much the idea with dynamic typing.  I find the
> > restrictions of static typing very convenient (well most of the time
> > :-) as they capture "stupid' errors.
> I disagree.  I wrote tens of thousands of lines of code in a (decent) dynamically typed language.  Now I am writing 
> thousands of lines of code in Haskell.  I also appreciate all my "stupid" errors being caught - this is a welcome 
> advantage, and I rather like it.  But I really really hate having to duplicate code for really dumb reasons.  So what 
> I want is not dynamic typing, just more powerful static typing.

At this point I wonder why it is necessary to have these features in
Haskell. Aren't there other languages which are closer to what you want?

More information about the Haskell-Cafe mailing list