
I've noticed that a large majority of fundeps I see in other people's libraries are written: class C a b | b -> a Where the dependent parameter appears first in the MPTC. Is there a reason for this? AFAIK, there isn't any semantic significance to the order of parameters in an MPTC. Why do many haskellers find this configuration more intuitive? Friendly, --Lane

Am Montag 11 Mai 2009 18:36:54 schrieb Christopher Lane Hinson:
I've noticed that a large majority of fundeps I see in other people's libraries are written:
class C a b | b -> a
Where the dependent parameter appears first in the MPTC. Is there a reason for this?
Yes. Generalised newtype deriving (perhaps others, but that's what jumped at me). Consider class MonadState s m | m -> s where ... newtype State s a = State { runState :: s -> (a,s) } instance Monad (State s) where ... instance MonadState s (State s) where ... newtype MySpecialState s a = MSS (State (s,Int) a) deriving (Monad, MonadState (s,Int))
AFAIK, there isn't any semantic significance to the order of parameters in an MPTC. Why do many haskellers find this configuration more intuitive?
Friendly, --Lane

Christopher Lane Hinson wrote:
I've noticed that a large majority of fundeps I see in other people's libraries are written:
class C a b | b -> a
Where the dependent parameter appears first in the MPTC. Is there a reason for this?
AFAIK, there isn't any semantic significance to the order of parameters in an MPTC. Why do many haskellers find this configuration more intuitive?
The order of parameters in an MPTC is significant if you want to use newtype deriving, which can only be used with the last parameter, by explicitly providing all other parameters. Tillmann

Christopher Lane Hinson schrieb:
I've noticed that a large majority of fundeps I see in other people's libraries are written:
class C a b | b -> a
Where the dependent parameter appears first in the MPTC. Is there a reason for this?
AFAIK, there isn't any semantic significance to the order of parameters in an MPTC. Why do many haskellers find this configuration more intuitive?
It's consistent with good style parameter ordering of functions: http://www.haskell.org/haskellwiki/Parameter_order
participants (4)
-
Christopher Lane Hinson
-
Daniel Fischer
-
Henning Thielemann
-
Tillmann Rendel