
I wrote:
Wolfgang Jeltsch
wrote: On Tuesday, 2003-08-05, 15:22, CEST, Nick Name wrote:
<snip>
This is called "dependent types" and is not a feature of haskell (nor of any language that I know); there was "cayenne" (try a google search) but I don't believe it is still mantained.
<snip>
BTW, why is there no general interest for such a thing as dependent types?
What negative consequences does their implementation have?
It depends on whether you just want to write functions to take in values of such types, or whether you want to write functions to return values of such types. Doing the former uses dependant products, which would require a significant extension to GHC's guts, but not (AIUI) inherently unpleasant. Doing the latter (AIUI) essentially requires dependant sums. Basically, a family of types A_i parameterized by a value i :: I is written, for long-honored traditional reasons too complex to get into here, Sigma i::I.A_i. Now, if you have such dependant sums, there's a bad interaction with polymorphism: either you must have a type alpha which cannot appear in a family of types A_i in a dependant sum, or, for any function f :: alpha -> alpha, there exists a type beta such that f cannot be aplied at either beta or Sigma i::Int.beta. Clear?
Actually, on second thought, I think this could be simplified to: if we have dependant types, then either there is a type which cannot be used in a dependant type, or for every polymorphic function there is a type it cannot be applied at. Jon Cast

Hi On Tue, 5 Aug 2003, Jon Cast wrote:
Actually, on second thought, I think this could be simplified to: if we have dependant types, then either there is a type which cannot be used in a dependant type, or for every polymorphic function there is a type it cannot be applied at.
This is why most sensible dependent type theories have a hierarchy of universes behind the scenes. You can think of * in Haskell as the lowest universe, inhabited by types. Kinds live in the next level up. Haskell stops there, but there's no need to. The point is that objects polymorphic in level n things belong to level n+1. This way, no paradox, no nontermination, entirely decidable typechecking. One benefit of presenting this hierarchy in a uniform manner is that it's perfectly feasible to specify operations under which each level is closed: universal and existential quantification, all your usual polymorphic data structures, so that [Int] is at level 0, whilst [*] is at level 1. Sure, you can't apply `the' polymorphic identity function at its own polymorphic type, but you can apply the level 1 polymorphic identity at the type of the level 0 polymorphic identity. You write id id. The machine can handle all the book-keeping of levels, so you never need to see those details, unless you do attempt to create a genuine paradox. I'm working on dependently typed programming because I can see some benefits for declarative programming from the way that more expressive types allow you to tell the typechecker more of the structure you have in mind when you write a program---the typechecker may then help you write it correctly. Other benefits include the static checking of data structure invariants (cashing out potentially as code which needs fewer run-time checks to be safe/correct), guaranteed absence of run-time errors, totality (should you choose to work in the terminating fragment) and sometimes even correctness (if your type is speccific enough). I sometimes get the impression that lots of functional programmers have read some paper in which it's demonstrated conclusively that dependent types are irredeemably hopeless. Could somebody put me out of my misery and drop me the reference? Not that I'm at all miserable Conor

On Wednesday, August 6, 2003, at 06:15 AM, C T McBride wrote:
This is why most sensible dependent type theories have a hierarchy of universes behind the scenes. You can think of * in Haskell as the lowest universe, inhabited by types.
Why wouldn't terms be the lowest universe? Sam Moelius

Samuel E Moelius, wrote (on Wed, 06 Aug 2003 at 15:35):
> On Wednesday, August 6, 2003, at 06:15 AM, C T McBride wrote: >> This is why most sensible dependent type theories have a hierarchy of >> universes behind the scenes. You can think of * in Haskell as the lowest >> universe, inhabited by types. > Why wouldn't terms be the lowest universe? A universe is a type of types/set-like-things, modulo a pile of subtleties. (The first of which is that it is actually a type of codes for types.) I think the term "universe", which afaik was introduced into type theory by Martin-Lof, was chosen for its use in the foundations of category theory in dealing with questions of "size" (smallness/largeness). Peter Hancock
participants (4)
-
C T McBride
-
hancock@spamcop.net
-
Jon Cast
-
Samuel E.Moelius III