Skip to content

Commit

Permalink
Consistently avoid infix syntax in the GSG and reinstantiate dlint (d…
Browse files Browse the repository at this point in the history
…igital-asset#5483)

We avoided infix syntax here for `elem` but still used it for
`notElem` which doesn’t make much sense. Also we lost the config to
disable the lint when integrating the example in this repo. This
resulted in our own code producing a lint which is obviously a bad
idea.

side note: I think this lint does make sense once you
are familiar with the syntax and I feel slightly bad about disabling
more and more lints so for now I’m keeping it in the config.

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Apr 8, 2020
1 parent e2a02ca commit 8d56ed3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/getting-started/code/daml-after/User.daml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ template User with
controller username
do
assertMsg "You cannot follow yourself" (userToFollow /= username)
assertMsg "You cannot follow the same user twice" (userToFollow `notElem` following)
assertMsg "You cannot follow the same user twice" (notElem userToFollow following)
archive self
create this with following = userToFollow :: following

Expand Down
10 changes: 10 additions & 0 deletions templates/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ genrule(
# use default .gitignore and .dlint.yaml if they don't exist in the template
cp -n $$SRC/default-gitignore $$OUT/$$d/.gitignore
cp -n $$SRC/default-dlint-yaml $$OUT/$$d/.dlint.yaml
# We avoid introducing infix syntax in the GSG so we disable
# the lint there.
if [ "$$d" = "create-daml-app" ]; then
cat >> $$OUT/$$d/.dlint.yaml <<EOF
# This rule is enabled by default but we avoid
# infix syntax here to keep things simple.
- ignore: {name: Use infix }
EOF
fi
done
## special cases we should work to remove
Expand Down
2 changes: 1 addition & 1 deletion templates/create-daml-app/daml/User.daml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ template User with
controller username
do
assertMsg "You cannot follow yourself" (userToFollow /= username)
assertMsg "You cannot follow the same user twice" (userToFollow `notElem` following)
assertMsg "You cannot follow the same user twice" (notElem userToFollow following)
archive self
create this with following = userToFollow :: following
-- FOLLOW_END

0 comments on commit 8d56ed3

Please sign in to comment.