[Haskell-beginners] Question about class declaration

Brent Yorgey byorgey at seas.upenn.edu
Fri Jul 24 08:44:32 EDT 2009


On Fri, Jul 24, 2009 at 09:41:34AM -0300, Rafael Gustavo da Cunha Pereira Pinto wrote:
> Hi folks,
> 
> Once in a while I stumble upon declarations like this:
> 
> class EditAction e a | e -> a where
>   apply :: a -> e -> a
> 
> 
> 
> Why is the vertical bar there? I understand that => defines a context, but
> can't find what is the "|" for.

It's a functional dependency: the e -> a means that the type e
determines the type a, that is, there can only be one instance of
EditAction for any particular type e.

-Brent


More information about the Beginners mailing list