@@ -324,6 +324,15 @@ Destructuring using case expressions
324324 a |> f >> g
325325 --> a |> f |> g
326326
327+ (f >> g) a
328+ --> g <| f a
329+
330+ (f >> g) <| a
331+ --> g <| f <| a
332+
333+ a |> (g << f)
334+ --> a |> g |> f
335+
327336
328337### Numbers
329338
@@ -3345,6 +3354,26 @@ expressionVisitorHelp (Node expressionRange expression) config context =
33453354 , moduleCustomTypes = context.moduleCustomTypes
33463355 }
33473356
3357+ Node parens (Expression.ParenthesizedExpression ((Node _ (Expression.OperatorApplication "<<" _ _ _)) as operationNode)) ->
3358+ pipingIntoCompositionChecks
3359+ { commentRanges = context.commentRanges
3360+ , extractSourceCode = context.extractSourceCode
3361+ , direction = CallStyle.RightToLeft
3362+ }
3363+ (\() ->
3364+ if List.isEmpty argsAfterFirst then
3365+ removeBoundariesFix applied
3366+
3367+ else
3368+ [ Fix.removeRange
3369+ { start = { row = parens.end.row, column = parens.end.column - 1 }
3370+ , end = parens.end
3371+ }
3372+ , Fix.insertAt (Node.range firstArg).end ")"
3373+ ]
3374+ )
3375+ operationNode
3376+
33483377 Node parens (Expression.ParenthesizedExpression ((Node _ (Expression.OperatorApplication ">>" _ _ _)) as operationNode)) ->
33493378 reversedCompositionChecks
33503379 { commentRanges = context.commentRanges
@@ -17755,7 +17784,7 @@ pipelineChecks :
1775517784 }
1775617785 -> Maybe (Error {})
1775717786pipelineChecks checkInfo =
17758- pipingIntoCompositionChecks { commentRanges = checkInfo.commentRanges, extractSourceCode = checkInfo.extractSourceCode } checkInfo.direction checkInfo.pipedInto
17787+ pipingIntoCompositionChecks checkInfo (always []) checkInfo.pipedInto
1775917788 |> onNothing
1776017789 (\() ->
1776117790 reversedCompositionChecks checkInfo (\() -> []) checkInfo.pipedInto
@@ -17825,22 +17854,26 @@ fullyAppliedLambdaInPipelineChecks checkInfo =
1782517854
1782617855
1782717856pipingIntoCompositionChecks :
17828- { commentRanges : List Range, extractSourceCode : Range -> String }
17829- -> CallStyle.LeftOrRightDirection
17857+ { context
17858+ | commentRanges : List Range
17859+ , extractSourceCode : Range -> String
17860+ , direction : CallStyle.LeftOrRightDirection
17861+ }
17862+ -> (() -> List Fix)
1783017863 -> Node Expression
1783117864 -> Maybe (Error {})
17832- pipingIntoCompositionChecks context compositionDirection expressionNode =
17865+ pipingIntoCompositionChecks context fixesFromParent expressionNode =
1783317866 let
1783417867 targetAndReplacement : { opToFind : String, replacement : String }
1783517868 targetAndReplacement =
17836- case compositionDirection of
17869+ case context.direction of
1783717870 CallStyle.RightToLeft ->
1783817871 { opToFind = "<<", replacement = "<|" }
1783917872
1784017873 CallStyle.LeftToRight ->
1784117874 { opToFind = ">>", replacement = "|>" }
1784217875 in
17843- case pipingIntoCompositionChecksHelp context targetAndReplacement compositionDirection expressionNode of
17876+ case pipingIntoCompositionChecksHelp context targetAndReplacement expressionNode of
1784417877 Nothing ->
1784517878 Nothing
1784617879
@@ -17852,7 +17885,7 @@ pipingIntoCompositionChecks context compositionDirection expressionNode =
1785217885 [ "Because of the precedence of operators, using " ++ targetAndReplacement.opToFind ++ " at this location is the same as using " ++ targetAndReplacement.replacement ++ "."
1785317886 , "To make it more idiomatic in Elm and generally easier to read, please use " ++ targetAndReplacement.replacement ++ " instead. You may need to remove some parentheses to do this."
1785417887 , "Here is an example:"
17855- ++ (case compositionDirection of
17888+ ++ (case context.direction of
1785617889 CallStyle.RightToLeft ->
1785717890 leftPipeExample
1785817891
@@ -17862,20 +17895,23 @@ pipingIntoCompositionChecks context compositionDirection expressionNode =
1786217895 ]
1786317896 }
1786417897 error.opToReplaceRange
17865- error.fixes
17898+ (fixesFromParent () ++ error.fixes)
1786617899 )
1786717900
1786817901
1786917902pipingIntoCompositionChecksHelp :
17870- { commentRanges : List Range, extractSourceCode : Range -> String }
17903+ { context
17904+ | commentRanges : List Range
17905+ , extractSourceCode : Range -> String
17906+ , direction : CallStyle.LeftOrRightDirection
17907+ }
1787117908 -> { opToFind : String, replacement : String }
17872- -> CallStyle.LeftOrRightDirection
1787317909 -> Node Expression
1787417910 -> Maybe { opToReplaceRange : Range, fixes : List Fix, firstStepIsComposition : Bool }
17875- pipingIntoCompositionChecksHelp context targetAndReplacement compositionDirection subExpression =
17911+ pipingIntoCompositionChecksHelp context targetAndReplacement subExpression =
1787617912 case Node.value subExpression of
1787717913 Expression.ParenthesizedExpression inParens ->
17878- case pipingIntoCompositionChecksHelp context targetAndReplacement compositionDirection inParens of
17914+ case pipingIntoCompositionChecksHelp context targetAndReplacement inParens of
1787917915 Nothing ->
1788017916 Nothing
1788117917
@@ -17898,12 +17934,12 @@ pipingIntoCompositionChecksHelp context targetAndReplacement compositionDirectio
1789817934 let
1789917935 continuedSearch : Maybe { opToReplaceRange : Range, fixes : List Fix, firstStepIsComposition : Bool }
1790017936 continuedSearch =
17901- case compositionDirection of
17937+ case context.direction of
1790217938 CallStyle.RightToLeft ->
17903- pipingIntoCompositionChecksHelp context targetAndReplacement compositionDirection left
17939+ pipingIntoCompositionChecksHelp context targetAndReplacement left
1790417940
1790517941 CallStyle.LeftToRight ->
17906- pipingIntoCompositionChecksHelp context targetAndReplacement compositionDirection right
17942+ pipingIntoCompositionChecksHelp context targetAndReplacement right
1790717943 in
1790817944 if symbol == targetAndReplacement.replacement then
1790917945 Maybe.map (\errors -> { errors | firstStepIsComposition = False })
0 commit comments