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
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,
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
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
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