CombinePipedModuleFunctionsAnalyzer
Problem
Subsequent collection functions like List.filter and List.map can sometimes be combined into List.choose.
let a b =
b
|> List.filter (fun x -> x < 20)
|> List.map (fun y -> y * 2)
Fix
let a b =
b
|> List.choose (fun x -> if x < 20 then Some(x * 2) else None)
val a: b: int list -> int list
val b: int list
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| op_Nil
| op_ColonColon of Head: 'T * Tail: 'T list
interface IReadOnlyList<'T>
interface IReadOnlyCollection<'T>
interface IEnumerable
interface IEnumerable<'T>
member GetReverseIndex: rank: int * offset: int -> int
member GetSlice: startIndex: int option * endIndex: int option -> 'T list
static member Cons: head: 'T * tail: 'T list -> 'T list
member Head: 'T
member IsEmpty: bool
member Item: index: int -> 'T with get
...
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| op_Nil
| op_ColonColon of Head: 'T * Tail: 'T list
interface IReadOnlyList<'T>
interface IReadOnlyCollection<'T>
interface IEnumerable
interface IEnumerable<'T>
member GetReverseIndex: rank: int * offset: int -> int
member GetSlice: startIndex: int option * endIndex: int option -> 'T list
static member Cons: head: 'T * tail: 'T list -> 'T list
member Head: 'T
member IsEmpty: bool
member Item: index: int -> 'T with get
...
val filter: predicate: ('T -> bool) -> list: 'T list -> 'T list
val x: int
val map: mapping: ('T -> 'U) -> list: 'T list -> 'U list
val y: int
val choose: chooser: ('T -> 'U option) -> list: 'T list -> 'U list
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
ionide-analyzers