On Fri, Jun 29, 2018 at 2:51 AM, Tom Ellis <tom-lists-haskell-cafe-2017@jaguarpaw.co.uk> wrote:
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

 
This in turn can be worked around using a newtype wrapper for each alternate instance you want.  I like this but I understand why it is often seen as awkward.

Ryan