[Haskell-cafe] MPTC or functional dependencies?

Petr P petr.mvd at gmail.com
Fri Dec 21 13:38:21 CET 2012


Dear Haskellers,

I'm working on a small library for representing semigroup (or monoid)
actions on a set <http://hackage.haskell.org/package/semigroups-actions>.
The MultiParamTypeClasses extension seems to be best suited for the task,
as a group can act on many sets, and a set can be acted on by different
groups:

    -- | Represents an action of semigroup @g@ to set @a at .
    --
    -- Laws: @'Endo' . 'act'@ must be a homomorphism of semigroups.
    class Semigroup g => SemigroupAct g a where
        act :: g -> (a -> a)

But soon I realized that with MPTC the compiler has problems inferring
types and I had to explicitly specify types when using `act` in many
places. Because it seems that in most cases a set will have only a single
group acting on it, I was thinking about using FDs:

    class Semigroup g => SemigroupAct g a | a -> g where

But on the other hand, this can limit the generality of the type class. I
cannot decide which one I should choose.

What would you suggest? According to your experience, would you choose
plain MPTC or FD?

Best regards,
Petr Pudlak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121221/8d8e811e/attachment.htm>


More information about the Haskell-Cafe mailing list