fundeps question

2002-12-15 Thread nalexand
I want to use functional dependencies in a way I've not yet seen: to enforce commutativity. I define class Mul a b c | a b -> c, b a -> c where mul :: a -> b -> c I want instance (Mul a b c) => Mul b a c where mul x y = mul y x do what I expect: if I can multiply a and b, then I can multiply

Fundeps question

2003-03-06 Thread Carlos Eduardo Scheidegger
Hello, I am currently toying with the idea of implementing a PostScript library in Haskell, and I am currently implementing a static, simplified version of the Postscript type checker using phantom types and functional dependencies. I am enriching the Postscript definitions with types so that

Fundeps question

2003-03-06 Thread Martin Sulzmann
There seems to be a mismatch between hugs and ghc. hugs -98 :version -- Hugs Version February 2001 accepts the following: == EqList.hs module EqList where data Nil = Nil data Cons x xs = Cons x xs class EqList a b c | a b -> c where comp :: a -> b -> c comp _ _ = error

Re: fundeps question

2002-12-15 Thread Ashley Yakeley
At 2002-12-14 15:27, [EMAIL PROTECTED] wrote: >I define > >class Mul a b c | a b -> c, b a -> c where mul :: a -> b -> c The two constraints are identical. Each one says "given a and b, you have c". What you want is essentially this: class (Mul b a c) => Mul a b c where mul :: a -> b ->

Re: fundeps question

2002-12-16 Thread Hal Daume III
Hi, I spent about a half hour toying around with this and came up with the following, which seems to work (in ghci, but not hugs -- question for smart people: which is correct, if either?)... class Mul a b c | a b -> c where mul :: a -> b -> c-- our standard multiplication, with fundeps d

Re: fundeps question

2002-12-16 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Hal Daume III <[EMAIL PROTECTED]> wrote: > I spent about a half hour toying around with this and came up with the > following, which seems to work (in ghci, but not hugs -- question for > smart people: which is correct, if either?)... Both are correct. Hugs fails

Re: fundeps question

2002-12-17 Thread Jeffrey R Lewis
On Monday 16 December 2002 18:18, Ashley Yakeley wrote: > In article <[EMAIL PROTECTED]>, > > Hal Daume III <[EMAIL PROTECTED]> wrote: > > I spent about a half hour toying around with this and came up with the > > following, which seems to work (in ghci, but not hugs -- question for > > smart peop