[Haskell] Type Class Question

2005-11-21 Thread Paul Govereau
Hello, I was hoping that someone could answer a question I have about the type class system. In Haskell, I cannot write a term with an exact constraint: data X = X bar :: Show X = X - String bar x = show x According to the Haskell 98 report, a qualifier can only be applied to type variables,

Re: [Haskell] Type Class Question

2005-11-21 Thread Paul Govereau
with just applying show to it. There's no need to actually assert that it's actually an instance of Show again. The only purpose of class constraints is to restrict polymorphism. If a function isn't polymorphic to begin with, you should never need them. - Cale On 21/11/05, Paul Govereau

Re: [Haskell] PROPOSAL: class aliases

2005-10-13 Thread Paul Govereau
On Oct 12, John Meacham wrote: [...] class Num a where (+), (*):: a - a - a (-) :: a - a - a negate :: a - a fromInteger :: Integer - a ideally we would want to split it up like so (but with more mathematically precise names): class Additive a

Re: [Haskell] Partially applied type class functions

2005-08-06 Thread Paul Govereau
my original program was a case similar to this last one. Thanks again for the quick response. Paul On Aug 05, Roberto Zunino wrote: Paul Govereau wrote: [snip] instance AbSyn Constraint where subst e n constr = let sub = subst e n -- :: AbSyn a = a - a in case constr

[Haskell] Partially applied type class functions

2005-08-05 Thread Paul Govereau
Hello, I have encountered a type error that I find quite puzzling. I would appreciate it if someone could help me understand what is going wrong. Here is the program: data Expr = Var String | Const Int data Constraint = Zero Expr | AndL Constraint class AbSyn a where subst :: Expr -

Re: [Haskell] A puzzle and an annoying feature

2004-11-24 Thread Paul Govereau
This is a great example, thanks for posting it. However, I feel like the real problem in this example is the lexically-scoped type variables declared with your function f. I am always surprised by the effects that lexically-scoped type variables can have on top-level declarations. Consider

Re: [Haskell] A puzzle and an annoying feature

2004-11-24 Thread Paul Govereau
I realize now that your original example did not actually have any such type variables. While playing around with your puzzle, I managed to introduce some. However, perhaps the lexically-scoped type variables are interesting in their own right. Sorry for the confusion, --Paul On Nov 24, Paul