containers
has an informal convention going on:
insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a
findWithDefault :: Ord k => a -> k -> Map k a -> a
The other-key-value-datatype argument order predates containers
, it was yanked directly from DData
(commit
) and all I can find from that era are mailing lists, which are a pain to traverse.
For new libraries, what is the correct convention?
To me it seems like placing the key at the leftmost position makes the most sense semantically. INLINE
-wise it also doesn’t seem to matter, arity is pretty much always “all arguments except the data structure(s)”.