[Haskell-cafe] Re: newbie : multi-parameter type classes

2007-08-24 Thread Christian Maeder
Thomas Girod wrote: class (Eq n, Eq e) = Topo a n e where empty:: a empty does not allow to infer the types n and e nodes:: a - [n] also nodes leaves the type e undetermined http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#functional-dependencies

[Haskell-cafe] Re: newbie : multi-parameter type classes

2007-08-24 Thread Christian Maeder
Thomas Girod wrote: Hi there. I'm trying to define a generic graph type here and don't understand on one error I get. Here I come. module Graph where class (Eq n, Eq e) = Topo a n e where empty:: a nodes:: a - [n] edges:: a - [e] This does not work

Re: [Haskell-cafe] Re: newbie : multi-parameter type classes

2007-08-24 Thread Matthew Brecknell
Unfortunately http://www.cse.ogi.edu/~mpj/pubs/fundeps.html is broken. http://web.cecs.pdx.edu/~mpj/pubs/fundeps.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] multi parameter type classes for NP problems

2006-12-20 Thread Joshua Ball
. Here is how I am trying to solve the problem, using multi-parameter type classes. class NPProblem inst cert where validates :: cert - inst - Bool certificates :: inst - [cert] decide :: inst - Bool decide i = any (\x - x `validates` i) $ certificates i Unfortunately, ghc throws

Re: [Haskell-cafe] multi parameter type classes for NP problems

2006-12-20 Thread Greg Buchholz
Joshua Ball wrote: Here is how I am trying to solve the problem, using multi-parameter type classes. class NPProblem inst cert where validates :: cert - inst - Bool certificates :: inst - [cert] decide :: inst - Bool decide i = any (\x - x `validates` i) $ certificates i

Re: [Haskell-cafe] multi parameter type classes for NP problems

2006-12-20 Thread Joshua Ball
That works. Thanks. I didn't realize you could put types in the expression itself. On 12/20/06, Greg Buchholz [EMAIL PROTECTED] wrote: Joshua Ball wrote: Here is how I am trying to solve the problem, using multi-parameter type classes. class NPProblem inst cert where validates :: cert

Re: [Haskell-cafe] Re: Fun with multi-parameter type classes

2004-08-21 Thread Sam Mason
karczma wrote: Actually, I would like to know what was the purpose of all that... I was writing some new code and wanted to break it into two parts, they should have very little knowledge of each other other than what methods are available in each (hence the classes). The actual types of the

Re: [Haskell-cafe] Fun with multi-parameter type classes

2004-08-20 Thread Henning Thielemann
On Thu, 19 Aug 2004, Sam Mason wrote: class Foo t where encode :: String - t decode :: t - String test = decode . encode This currently fails, because the type checker insists on trying to figure out what its type should be - even though it shouldn't be needed. In

[Haskell-cafe] Fun with multi-parameter type classes

2004-08-19 Thread Sam Mason
Hi, I've been getting into Haskell over the past few months and have just come up against a bit of a brick wall when trying to encapsulate some of the data structures in my code nicely. Basically what I want to have, is a type class where one of the intermediate values is opaque with respect to

Re: [Haskell-cafe] Fun with multi-parameter type classes

2004-08-19 Thread Marius Nita
On Thu, Aug 19, 2004 at 05:42:10PM +0100, Sam Mason wrote: Hi, I've been getting into Haskell over the past few months and have just come up against a bit of a brick wall when trying to encapsulate some of the data structures in my code nicely. Basically what I want to have, is a type

Re: [Haskell-cafe] Fun with multi-parameter type classes

2004-08-19 Thread Jon Cast
Hi, I've been getting into Haskell over the past few months and have just come up against a bit of a brick wall when trying to encapsulate some of the data structures in my code nicely. Basically what I want to have, is a type class where one of the intermediate values is opaque with

[Haskell-cafe] Re: Fun with multi-parameter type classes

2004-08-19 Thread karczma
Sam Mason writes: Jon Cast wrote: The intermediate type /is/ needed---it's a (hidden) parameter to your `encode' and `decode' functions. Why do you think it shouldn't be? Because I couldn't see the woods for the trees. I think I had almost figured out what I was asking (the impossible) before

Re: [Haskell-cafe] Re: Fun with multi-parameter type classes

2004-08-19 Thread Sam Mason
karczma wrote: Don't forget that this is the toplevel business, not a universal disease. GHCi says Prelude :t (show . read) (show . read) :: String - String and doesn't complain. But if you define bz = show . read the attempt to load this definition (file: ctest.hs) results in:

Re: Multi-parameter type classes

1998-07-01 Thread Simon L Peyton Jones
|5. In the signature of a class operation, every constraint must | mention at least one type variable that is not a class type | variable. Thus: ... |class C a where | op :: Eq a = (a,b) - (a,b) | | is not OK because the constraint (Eq a)

Re: Multi-parameter type classes

1998-06-30 Thread Andreas Rossberg
Simon L Peyton Jones wrote: GHC 3.02 supports multi-parameter type classes, but I have been guilty of not documenting precisely what that means. I've now summarised the extensions, informally but I hope precisely, at http://www.dcs.gla.ac.uk/multi-param.html That does not seem

Multi-parameter type classes in GHC 3.01

1998-02-25 Thread Simon L Peyton Jones
PS. Could somebody inform me what is the current status of multi-parametric classes? GHC 3.01 supports multi-parameter type classes in more or less the form described in the last section of "Type classes: an exploration of the design space"