[Haskell] Re: Functional dependencies and type inference (2)

2005-12-06 Thread Stefan Monnier
>> > instance CpsForm t t where >> This can't be right, can it? > In general no: the CPS of a function certainly doesn't fit the above > pattern. So, if the source language has abstractions (the language in > the original message didn't), we have to add another instance for > CpsForm. But any othe

[Haskell] Re: Functional dependencies and type inference (2)

2005-12-04 Thread oleg
Stefan Monnier wrote: > > instance CpsForm t t where > > This can't be right, can it? In general no: the CPS of a function certainly doesn't fit the above pattern. So, if the source language has abstractions (the language in the original message didn't), we have to add another instance for CpsFor

[Haskell] Re: Functional dependencies and type inference (2)

2005-12-03 Thread Stefan Monnier
> instance CpsForm t t where This can't be right, can it? After CPS conversion a term of type "a -> b" won't have type "a -> b" but rather something like "a * (b -> c) -> c". Stefan ___ Haskell mailing list Haskell@haskell.org http://www.haske

[Haskell] Re: Functional dependencies and type inference (2)

2005-11-30 Thread oleg
Louis-Julien Guillemette wrote: > Say we are using a GADT to represent a simple language of boolean > constants and conditionals, > > data Term a where >B:: Bool -> Term Bool >Cnd :: Term Bool -> Term t -> Term t -> Term t > > and we would like to perform a type-safe CPS conversion ov

[Haskell] Re: Functional dependencies interfere with generalization

2004-01-28 Thread oleg
I'm sorry to open an old wound. I've just had an insight for a clarification. On Nov 26, 2003 Ken Shan wrote: > Consider the following code, which uses type classes with functional > dependencies: > > {-# OPTIONS -fglasgow-exts #-} > module Foo where > class R a b | a -> b where r ::

Re: Functional dependencies interfere with generalization

2003-11-27 Thread Ken Shan
On 2003-11-27T07:51:37-0800, Brandon Michael Moore wrote: > I agree that the typechecker could handle this better, but I don't see why > you should need types like this. You should be able to use > > rr :: (R a b) => a -> (b,b) > > and > > data RAB a = forall b. (R a b) => RAB (a,b) > > equall

Re: Functional dependencies interfere with generalization

2003-11-27 Thread Brandon Michael Moore
On Wed, 26 Nov 2003, Ken Shan wrote: > Hello, > > Consider the following code, which uses type classes with functional > dependencies: > > {-# OPTIONS -fglasgow-exts #-} > module Foo where > class R a b | a -> b where r :: a -> b > > -- 1 > rr :: (R a b1, R a b2) => a -> (b1,

RE: Functional dependencies and Constructor Classes

2002-11-20 Thread Martin Sulzmann
Mark P Jones writes: > | The issue I want to raise is whether constructor classes are > | redundant in the presence of FDs > > No, they are not comparable. > Allow me to make the following bold claim. Assume we are given a program that uses the Haskell functor class as in class Functor f

Re: Functional dependencies and Constructor Classes

2002-11-19 Thread Yoann Padioleau
Martin Sulzmann <[EMAIL PROTECTED]> writes: > Yoann Padioleau writes: > > nevertheless i found constructor class more elegant for many problems. > > Your solution is less elegant that the one using constructor classes. > > > > Yes, the current presentation of constructor classes might be easi

RE: Functional dependencies and improvement

2002-11-18 Thread Mark P Jones
Martin, | In my previous example I employed FD's to | improve constraints. However, there are cases where FD's seem | to be overly restrictive. Yes, of course! So it will be for any extension of the type system that retains both decidability and soundness. The particular form of "improvement"

RE: Functional dependencies and Constructor Classes

2002-11-18 Thread Mark P Jones
Hi Martin, | The issue I want to raise is whether constructor classes are | redundant in the presence of FDs No, they are not comparable. Let fds = functional dependencies ccs = constructor classes Example of something you can do with ccs but not fds: data Fix f = In (f (Fix f)) Examp

Re: Functional dependencies and Constructor Classes

2002-11-18 Thread Martin Sulzmann
Yoann Padioleau writes: > nevertheless i found constructor class more elegant for many problems. > Your solution is less elegant that the one using constructor classes. > Yes, the current presentation of constructor classes might be easier to comprehend. > I found too that type error message

Re: Functional dependencies and Constructor Classes

2002-11-18 Thread Yoann Padioleau
Martin Sulzmann <[EMAIL PROTECTED]> writes: > Hi, > > I was wondering whether other people made similiar observations. > Functional dependencies seem to be expressiveness enough to encode > some of the kinding rules required for Constructor Classes. read this page: http://cvs.haskell.org/Hugs/

RE: functional dependencies

2002-07-24 Thread Ashley Yakeley
At 2002-07-23 09:06, Simon Peyton-Jones wrote: >Dead right! Imagine there was a method in class D: > > class C a b => D a where > op :: a -> b > >The type of 'op' is > > op :: D a => a -> b > >You can't really expect that the 'b' here is determined by 'a'! Agreed. If you we

RE: functional dependencies

2002-07-23 Thread Simon Peyton-Jones
I'm just catching up with some old mail here. Iavor writes: | class C a b | a -> b | class C a b => D a | | vs. | | class C a b | a -> b | class C a b => D a b | | Hugs accepts both of those, while GHC insists on the second. | The first example is a little shorter and one might argue that i

Re: Functional Dependencies

1999-09-14 Thread Ross Paterson
Mark P Jones wrote: | | Neat. And it solves a problem I was kludging around with explicit, | | existentially quantified dictionaries. | | Great! Can I look forward to hearing more about that some time? OK, it's to do with arrows: > class Arrow a where > arr :: (b -> c) -> a b c >

RE: Functional Dependencies

1999-09-14 Thread Mark P Jones
Hi Fermin, | Should redundant dependencies trigger an error or a warning? I'd | say that if I'm writing some haskell code, I wouldn't mind if a | redundancy is flagged as an error; most likely, it'd take a short | time to fix. However, if someone is generating haskell automatically | (maybe with

RE: Functional Dependencies

1999-09-13 Thread Fermin Reig Galilea
> > | Also, you say a dependency with zero variables on the right side is > | syntactically correct, but later you say it will be reported as an > | error because it says nothing. Why bother? > > Point taken. In fact that same database text I mentioned above > prohibits functional dependencies

RE: Functional Dependencies

1999-09-13 Thread Mark P Jones
| Neat. And it solves a problem I was kludging around with explicit, | existentially quantified dictionaries. Great! Can I look forward to hearing more about that some time? | On a superficial note, how about | class C a b c | (a,b) => c where ... | for | class C a b c | a b -> c w

Re: Functional Dependencies

1999-09-13 Thread Ross Paterson
Mark P Jones wrote: > A couple of months ago, I developed and implemented an extension to > Hugs that has the potential to make multiple parameter type classes > more useful. The key idea is to allow class declarations to be > annoted with `functional dependencies'---an idea that has previously >

RE: Functional Dependencies

1999-09-12 Thread Mark P Jones
Hi Heribert, Thanks for your feedback! | at the end of section 2 of http://www.cse.ogi.edu/~mpj/fds.html you | might want to mention that there is a "standard" work-around whenever a | type constructor is needed but not available: Introduce a newtype. Yes, an in fact this idea is mentioned at t

Re: Functional Dependencies

1999-09-12 Thread Heribert Schuetz
Hi Mark, at the end of section 2 of http://www.cse.ogi.edu/~mpj/fds.html you might want to mention that there is a "standard" work-around whenever a type constructor is needed but not available: Introduce a newtype. > import Bits > class Collects e c where >empty :: c e >insert :: e ->