Re: [Haskell-cafe] Named field syntax

2008-08-30 Thread Johannes Waldmann

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

J.W.




signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Named field syntax

2008-08-29 Thread Maurí­cio

Hi,

I see that this works:

data Test = Test Integer String

This also works:

data Test = Test {a::Integer,b::String}

However, this doesn't:

data Test = Test Integer {b::String}

Is there some way to name only a single, or a few,
of some data type fields?

Thanks,
Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Named field syntax

2008-08-29 Thread Ketil Malde
Maurí­cio [EMAIL PROTECTED] writes:

 However, this doesn't work:

 data Test = Test Integer {b::String}

 Is there some way to name only a single, or a few,
 of some data type fields?

data Test = Test Integer String

b :: Test - String
b (Test i s) = s

:-)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Named field syntax

2008-08-29 Thread Johannes Waldmann

 data Test = Test Integer {b::String}

positional (= unnamed) record notation is a language design error :-)
and its use should be discouraged. - J.W.




signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Named field syntax

2008-08-29 Thread Brandon S. Allbery KF8NH

On 2008 Aug 29, at 9:30, Maurí cio wrote:

However, this doesn't:

data Test = Test Integer {b::String}

Is there some way to name only a single, or a few,
of some data type fields?



There's no shorthand for it, no (and therefore you can't get one that  
works for pattern matching).  Personally, I haven't found it a  
hardship, because you can always used the unnamed field syntax.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Named field syntax

2008-08-29 Thread Roman Cheplyaka
* Johannes Waldmann [EMAIL PROTECTED] [2008-08-29 15:39:15+0200]
  data Test = Test Integer {b::String}
 
 positional (= unnamed) record notation is a language design error :-)
 and its use should be discouraged. - J.W.

Polluting namespace with unneeded functions should not be encouraged
either. Consider for instance defining datatype for 3x3 matrix.
Would the absence of unnamed record notation make you more happy?

-- 
Roman I. Cheplyaka :: http://ro-che.info/
kzm: My program contains a bug. How ungrateful, after all I've done for it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Named field syntax

2008-08-29 Thread Philip Weaver
On Fri, Aug 29, 2008 at 1:59 PM, Roman Cheplyaka [EMAIL PROTECTED] wrote:

 * Johannes Waldmann [EMAIL PROTECTED] [2008-08-29
 15:39:15+0200]
   data Test = Test Integer {b::String}
 
  positional (= unnamed) record notation is a language design error :-)
  and its use should be discouraged. - J.W.

 Polluting namespace with unneeded functions should not be encouraged
 either. Consider for instance defining datatype for 3x3 matrix.
 Would the absence of unnamed record notation make you more happy?


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



 --
 Roman I. Cheplyaka :: http://ro-che.info/
 kzm: My program contains a bug. How ungrateful, after all I've done for it.
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe