Since I have started coding in PureScript a couple of month ago, I find myself constantly switching between
where. There is a reddit post which tasks about this:
Also, I thought functions are best expressed with verbs like
getSomething to distinguish them from constants. Then I saw function names like
In the reddit post the user MtnViewMark makes a strong case of “The idiomatic style, models how such expressions are said in English”. As I understood it, code as you speak in math, e.g.
y = sin(... as “y equals the sin of …”.
>>= translates to “is bound to” I guess. Thus, constants should be
h etc. and nouns for functions names.
where fits better to
On the other side, I think idiomatic style breaks down pretty quickly because a lot of names already exist and short sentences are easier to read than long ones. Thus function names should be verbs, usage of
<#> and the code reads like “replace something and then convert and then note”.
Has anybody come up with a consistent approach of how to name new functions other than
is... for checks,
mk... for constructors and design for qualified import or can point to a library or code which reads well?