[Haskell-cafe] need help understanding how to specify constraints on monads
Tom Ellis
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Fri Jun 29 06:51:22 UTC 2018
On Thu, Jun 28, 2018 at 03:23:18PM -0700, Dennis Raddle wrote:
> My idea was to create a typeclass, Comp, parameterized on the the
> composition data structure ('comp'), the data type of a single "move" or
> step to be added, ('step'), and the type of an evaluation units ('eu').
>
> class Comp comp eu step | comp -> eu, comp -> step where
> listPossibleSteps :: comp -> [step]
> addStep :: comp -> step -> comp
> evalComp :: eu -> comp -> comp
Have you considered just making a record?
data Comp comp eu step = Comp {
listPossibleSteps :: comp -> [step],
addStep :: comp -> step -> comp,
evalComp :: eu -> comp -> comp
}
If you make it a class then you end up in the bizarre situation where you
can only have one collection of functionality for each type `comp`.
Tom
More information about the Haskell-Cafe
mailing list