Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General check and fix cleanup #237

Merged
merged 82 commits into from
Oct 4, 2023

Conversation

lue-bird
Copy link
Collaborator

@lue-bird lue-bird commented Oct 2, 2023

  • Supply all checkInfo arguments implicitly
  • group related type properties
  • remove fixToLeft/RightRange in favor of keepOnlyFix / replaceBySubExpressionFix
  • remove errorToLeft/RightRange in favor of operatorRange / Range.combine of fn and side
  • tweak operation error infos
    • (-), (+), (*), (/), (//), (++), (<), (<=), (>), (>=), (&&), (||), (&&), (==), (/=)
    • unnecessaryMessage, unnecessaryDetails, alwaysSameDetails and other error helpers
  • lean more into operationSides
  • Add unnecessaryCompositionAfterEmptyCheck
  • Add last.argCount to CompositionIntoCheckInfo
  • allow ConstructWithOneArg as empty directly by requiring an extra is property
  • listDetermineLength use getSpecificFnCall for singleton

Note that unnecessaryCompositionAfterEmptyCheck enables new simplifications, e.g. Task.map f << Task.fail --> Task.fail which are deliberately not included in this PR.

Switching to Fn.Array.map will be the next PR

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

The branch can be tried out by running:

elm-review --template jfmengels/elm-review-simplify/preview

@jfmengels
Copy link
Owner

LGTM so far (note for me, last commit I checked was Remove unused errorToLeft/RightRange)

@lue-bird lue-bird added the bug Something isn't working label Oct 3, 2023
src/Simplify.elm Outdated Show resolved Hide resolved
Copy link
Owner

@jfmengels jfmengels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good to me so far 👍

, parentRange = checkInfo.parentRange
, first = checkInfo.left
collectionUnionWithLiteralsChecks
{ first = checkInfo.left
, second = checkInfo.right
, operationRange = checkInfo.operatorRange
, operation = "++"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional simplification: The operator is in checkInfo.operation

src/Simplify.elm Outdated Show resolved Hide resolved
@lue-bird
Copy link
Collaborator Author

lue-bird commented Oct 3, 2023

Fighting elm/compiler#2312, this somehow worked out now.
However, I'm not confident this extensible record type alias extending TypeProperties thing won't cause headaches in the future.

E.g. setChecks has exactly one property nesting (the most intuitive one) which leads to a compiler while any other nesting compiles fine.

Sensible solutions might be to not alias TypeProperties in every other properties type alias or to completely switch to record fields for the properties. What do you say?

@jfmengels
Copy link
Owner

I'm fine with not having TypeProperties in every other properties type alias 👍
But feel free to switch to the other approach if you think it will work better 👍

@lue-bird lue-bird changed the title WIP: General check and fix cleanup General check and fix cleanup Oct 3, 2023
@lue-bird lue-bird marked this pull request as ready for review October 3, 2023 21:38
@jfmengels jfmengels force-pushed the general-check-and-fix-cleanup branch from 40ce5df to 6d745b1 Compare October 4, 2023 06:35
@jfmengels jfmengels merged commit 6d745b1 into jfmengels:main Oct 4, 2023
@jfmengels
Copy link
Owner

Great work 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants