Strange warning FSharpLint

I am trying to override the List.distinct function:

 let inline distinct list = let folder curr = function | [] -> [curr] | l -> if List.contains curr l then l else curr :: l List.foldBack folder list [] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

I got a warning that

List.foldBack fx [] can be reorganized to x

However, this does not matter much to me, since it leads me to return to the original list without executing separate logic.

Is this an FSharpLint error?

+6
source share
1 answer

This seems to be the wrong rule. Take a look at this excerpt from FSharpLint 's default setting :

 List.fold fx [] ===> x Array.fold fx [||] ===> x List.foldBack fx [] ===> x Array.foldBack fx [||] ===> x 

The same goes for fold and foldback here, so it does not follow the differences in signatures between them.

The initial state order and collection arguments must be inverted; see the mnemonic approach used in the definition of foldback .

+6
source

Source: https://habr.com/ru/post/1012167/


All Articles