Lambda the Ultimate

inactiveTopic cayenne: haskell with dependent types
started 7/26/2001; 5:30:53 AM - last post 7/29/2001; 1:29:18 PM
pixel - cayenne: haskell with dependent types  blueArrow
7/26/2001; 5:30:53 AM (reads: 1142, responses: 5)
cayenne: haskell with dependent types
The main difference between Haskell and Cayenne is that Cayenne has dependent types, i.e., the result type of a function may depend on the argument value, and types of record components (which can be types or values) may depend on other components.

Having dependent types and combined type and value expressions makes the language very powerful. It is powerful enough that a special module concept is unnecessary; ordinary records suffice.
Posted to functional by pixel on 7/26/01; 5:31:20 AM

Ehud Lamm - Re: cayenne: haskell with dependent types  blueArrow
7/27/2001; 11:05:11 AM (reads: 1174, responses: 0)
the result type of a function may depend on the argument value, and types of record components (which can be types or values) may depend on other components.

Seems to me this can be quite confusing...

Chris Rathman - Re: cayenne: haskell with dependent types  blueArrow
7/28/2001; 9:45:18 AM (reads: 1172, responses: 1)
Wouldn't this be related to the concept of covariance?

As for confusing, look at the posting on the Python division operator. Does 5/2 return 2.5 or 2? In the current case, the return result of the division operator (which is really a dyadic function) is context sensitive to the types of parameters. Give it two integers and it returns an integer. Give it two floats and it returns a float. Give it an integer and a float and it returns a float.

Such coercion in operator overloading seems to be taken to extremes in languages like C++. Of course, the question from an orthogonal approach to languages is why built in functions (and operators) behave differently than user defined functions. When a mismatch occurs, it usually results in limiting the extensibility of the language.

Ehud Lamm - Re: cayenne: haskell with dependent types  blueArrow
7/29/2001; 10:30:07 AM (reads: 1233, responses: 0)
I didn't really read about cayenne but I think we are talking more than overloading here. Notice Pixel wrote the result type of a function may depend on the argument value. Overloading allows the result type to depend on the type of the argument.

pixel - Re: cayenne: haskell with dependent types  blueArrow
7/29/2001; 10:58:18 AM (reads: 1159, responses: 1)
One could say that dynamic language have already been handling this for quite a few time now:

pixel@leia:~>irb
irb(main):001:0> i = 100
100
irb(main):002:0> (i*i).class
Fixnum
irb(main):003:0> i = 10000000
10000000
irb(main):004:0> (i*i).class
Bignum

(irb is interactive ruby)

Cayenne tries to mix this power with static typing. This is possible for compile-time values:

pixel@leia:~>ocaml
        Objective Caml version 3.01

# Printf.printf "%d %s\n" ;; - : int -> string -> unit = <fun>

But caml solution is not generic, since you can't write your own printf. Cayenne tries to give this power to the user. In fact the main problem in this is mainly syntaxic: how to give the user such a power?

Ehud Lamm - Re: cayenne: haskell with dependent types  blueArrow
7/29/2001; 1:29:18 PM (reads: 1247, responses: 0)
Well in Ada you can return a class'wide type from a function, and return specific types according to need. Ada knows to dispatch on return values of functions (as opposed to C++, IIRC).