On Wed, 2007-02-07 at 19:13 -0500, Jacques Carette wrote:
> skaller wrote:
> > However in typeclasses, since equality is a requirement
> > for ordering, and because stuff is passed implicitly, it
> > seems there is no sane distinction: even if you don't
> > export == from Eq in Ord, if you pass Ord to a function
> > you get a type which satisfies Eq anyhow, so you can
> > always just open Eq (and it should be perfectly safe).
> >   
> True - for Esq.  But is "perfectly safe" a syntactic or a semantic 
> condition?  If it is syntactic, then it is thoroughly safe to generalize 
> this.  If it is special to Eq/Ord, you have a real problem.

In Felix it isn't safe because Felix has non-propagating constraints**.
This is a bug of course, but a rather hard one to fix.

Indeed typeclasses are one way to fix it, since they encapsulate
constraints and allow them to propagate.

In Haskell, which in particular gains little benefit from
constraints in typeclasses since unlike Felix it doesn't support
typeclasses with multiple type arguments, I would have to guess
these things are the same for the simple reason there IS no
way to 'inherit' for the purpose of export as opposed to use:
in Haskell all you can do is

class B t => D t where ...

do the B constraint is always exported: otherwise you'd have
to write

        f :: D t, B t => ...

in functions and list all the classes in the tree.
Though perhaps I misunderstand..

** Felix allows stuff like

        [t,u where P(t,u) ]

and more particularly has a typematch facility which along
with type lambdas appears equivalent to Jay's pattern calculus,
albiet slighly more complex (two combinators instead of one).

Typeclasses use the syntax

        [t with P[t,u]]

which always confuses me: 'where' introduces an arbitrary
set of constraints, whereas 'with' introduces a typeclass
style constraint. Even more confusing, and in fact probably
unsound, you can do

        fun f[x:P]

which sometimes means:

        fun f[x where P[x]] // constraint

and sometimes means

        fun f[x where x isin p] // typeset

and sometimes means

        fun f[x:P] // P is a meta type eg TYPE->TYPE

at this stage the weak kinding system breaks down.
Stuff that works now only works due to some simplified
hackery. The different kinds of constraints aren't
combinatorially distinguished (that is, you can't
get it right by recursive analysis of the term).

There's enough stuff there to want to go back and get
it right, i.e. do some theory and implement it.
In particular constraints are really subtypes of metatypes,
but Felix has no syntactic support for subtyping.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to