Skip to content
Discussions/App Development/Daml Linter preference - Infix versus PrefixForum ↗

Daml Linter preference - Infix versus Prefix

App Development9 posts203 views3 likesLast activity Feb 2022
ME
meetOP
Feb 2022
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?

LU
Luciano
Feb 2022

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

CO
cocreature
Feb 2022

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.

ME
meet
Feb 2022

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 !

BE
bernhard
Feb 2022

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 ∉.

GE
georg
Feb 2022

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

ME
meet
Feb 2022

@georg same :joy:

LU
Luciano
Feb 2022
bernhard:

∈ and ∉

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

GE
georg
Feb 2022

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

← Back to Discussions