When writing deriveFmap or deriveFilter, it's often nice to write
the predicate function inline. Since that can often take
multiple arguments, the code reads more nicely when
the function comes second and the slice comes first,
so it's clear at first glace what slice is being operated on
before starting to read the function itself.
For example:
items := deriveFmap(otherItems, func(i OtherItem) Item {
return OtherItem{
Foo: i.Foo,
Bar: i.Bar,
}
})
rather than:
items := deriveFmap(func(i OtherItem) Item {
return OtherItem{
Foo: i.Foo,
Bar: i.Bar,
}
}, otherItems),
Alternatively, the goderive code could allow both forms and generate the
expected function signature based on the argument types that are passed
in.
When writing deriveFmap or deriveFilter, it's often nice to write
the predicate function inline. Since that can often take
multiple arguments, the code reads more nicely when
the function comes second and the slice comes first,
so it's clear at first glace what slice is being operated on
before starting to read the function itself.
For example:
rather than:
Alternatively, the goderive code could allow both forms and generate the
expected function signature based on the argument types that are passed
in.