Difference Argument Order

Ashley Yakeley ashley at semantic.org
Sun May 22 20:42:34 EDT 2005


Which of these argument orders is more intuitive to you?

1. This one makes more sense when considering the function formed by 
applying one argument:

add :: Diff -> Absolute -> Absolute
add d a = a + d
subtract :: Diff -> Absolute -> Absolute
subtract d a = a - d
diff :: Absolute -> Absolute -> Diff
diff a b = b - a

So "add x", "subtract y" and perhaps "diff z" are intuitively useful 
functions. And we also have "subtract = add . negate".

2. This one is more familiar for the English language and for the 
standard operators:

add :: Absolute -> Diff -> Absolute
add a d = a + d
subtract :: Absolute -> Diff -> Absolute
subtract a d = a - d
diff :: Absolute -> Absolute -> Diff
diff a b = a - b

-- 
Ashley Yakeley, Seattle WA



More information about the Libraries mailing list