Daml Linter preference - Infix versus Prefix

Suggestion: Use infix
Found:
  notElem p (signatory this)
Perhaps:
  p `notElem` signatory this

Why is using infix considered better quality code than using prefix as per the Daml linter?

1 Like

My guess is that the infix version gets rid of the parentheses. I think that’s the rule which is triggering the linter.

It’s not primarily about parentheses and it’s not triggered because of that, it’s a custom rule.

The usual argument for using the infix version is that in that case, the argument order corresponds to how you would phrase things in English “x is not an element of y”. In the prefix version it is less clear what the first and second argument’s role is.

That said, I think we dropped a similar rule for elem, and if there’s something resembling consensus I have no issues dropping this one.

Yep, my example just happened to contain a parenthesis - get the same with notElem 1 [2,3]
To me, it makes sense to apply the same linting rule for notElem as we did for elem

Thanks @cocreature !

I for one prefer infix to prefix for mathematical operations because it matches how I would read and parse statements on paper. I think of elem and notElem as ∈ and ∉.

Agree it reads better, but I just hate the `backticks` :slight_smile:

1 Like

@georg same :joy:

Should we add these as unicode operators? :fire: :laughing: ? Pretty sure this was restricted …

Oooh yes! And then alias :crazy_face: for fmap and :face_vomiting: for fromSome => :100:

1 Like