[Haskell-cafe] Got problems with classes

2009-08-17 Thread Grigory Sarnitskiy
Hello! I can't understand why the following dummy example doesn't work. {-# OPTIONS -XTypeSynonymInstances #-} {-# OPTIONS -XFlexibleInstances #-} module Main where import Data.Array.Unboxed class Particle p type ParticleC = (Double, Double, Double) instance Particle ParticleC class

Re: [Haskell-cafe] Got problems with classes

2009-08-17 Thread Bulat Ziganshin
Hello Grigory, Monday, August 17, 2009, 10:35:33 AM, you wrote: Hello! I can't understand why the following dummy example doesn't work. http://haskell.org/haskellwiki/OOP_vs_type_classes shortly speaking, throw away your OOP experience and learn new paradigm from scratch. also,

Re: [Haskell-cafe] Got problems with classes

2009-08-17 Thread Neil Brown
Hi, One reason (there may be more) is as follows: Grigory Sarnitskiy wrote: class Configuration c where getParticleI :: (Particle p) = c - Int - p This type signature declares that for any type c that has a Configuration instance (and an Int), you can give me back something that is of

Re: [Haskell-cafe] Got problems with classes

2009-08-17 Thread Job Vranish
I'm not exactly sure what you're trying to do, but the problem is that you're trying to return a specific value where the type signature is polymorphic. getParticleI returns a p, (with the constraint that p is a type in the class Particle) This means that getParticleI can be called in any

Re: [Haskell-cafe] Got problems with classes

2009-08-17 Thread Grigory Sarnitskiy
Thank you all, and especially Bulat. I've folowed the links and solved the problem in a new way. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe