newtype Transformation = Transformation { (<+>) :: SPLModel -> InstanceModel -> InstanceModel } data SelectScenarios = SelectScenarios { scIds :: [Id] } scenarioTransform scenario = Transformation $ \spl inst -> something testScenario = SelectScenarios [] test = scenarioTransform testScenario <+> undefined Don't use typeclasses unless you really need to. Higher-order functions are usually what you want. -- ryan On Tue, Dec 1, 2009 at 3:21 PM, rodrigo.bonifacio <rodrigo.bonifacio@uol.com.br> wrote:
Thanks Luke.
In fact I, will have different implementations of the Transformation type. Something like:
data SelectScenarios = SelectScenarios {
scIds :: [Id]
}
And then I should be able to make SelectScenarios a kind of Transformation. So I think that I really need a class. What do you think about it?
instance Transformation SelectScenario where
(<+>) ....
Regards,
Rodrigo.
Em 01/12/2009 19:39, Luke Palmer < lrpalmer@gmail.com > escreveu:
On Tue, Dec 1, 2009 at 11:21 AM, David Menendez wrote:
On Tue, Dec 1, 2009 at 1:00 PM, rodrigo.bonifacio wrote:
Dear all, I wrote the following types:
class Transformation t where (<+>) :: t -> SPLModel -> InstanceModel -> InstanceModel
data Configuration = forall t . Transformation t => Configuration (FeatureExpression, [t]) type ConfigurationKnowledge = [Configuration]
I would suggest doing away with the class in a case like this.
data Transformation = Transformation { (<+>) :: SPLModel -> InstanceModel -> InstanceModel }
data Configuration = Configuration FeatureExpression [Transformation]
I suspect that it was OO heritage that l ed you to want a class here? Forget that! :-)
Luke
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe