[Haskell-cafe] Named field syntax

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Sat Aug 30 09:33:15 EDT 2008

> Consider for instance defining datatype for 3x3 matrix.

I think the only sensible modelling for that
would use dependent types.

> Also, if positional record notation is a design error, then is it also a 
> design error not to require all arguments to be explicitly associated 
> with named formal parameters at a function call site (e.g. f(x = 1, y = 
> 2, z = 3))?

well, same question for incomplete "case" expressions.
Would you rule them out?

Leaving out some parameter associations would be possible
if we could declare default parameters
(in record types and function declarations) -

but this conflicts with partial application.
if you define  f (x :: Int) (y :: Int = 42) :: Int,
and write  (f 0), does it have type Int -> Int (partial app)
or type Int (using the default)?

I understand no-one seriously wants to remove partial application
for functions but if we (hypothetically, but we're in the *-cafe)
forbid positional notation for record constructors,
then we could have default values in record types,
and I can imagine quite some applications for that,
and especially so if the default value can be defined
to depend on the (other) values (that are given on construction).

Well, my horror for positional notation is basically
that introducing or removing a component/parameter
breaks all code that uses the type/function.
So, perhaps instead of changes in the language
I just want a refactoring tool that supports
* change function signature (remove, insert, swap parameters,
   including all necessary changes at call sites)
* for data declaration, convert positional to named notation


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080830/2f984052/signature.bin

More information about the Haskell-Cafe mailing list