-
-
Notifications
You must be signed in to change notification settings - Fork 294
Description
#422 just gave me an idea. When I write a long, complex pipeline, I will often make a type error somewhere in the pipeline. What I've been doing to solve those type errors is to turn a pipeline into a series of let
statements, so that the code lens will tell me what type my data is at each step of the pipeline. But it would be useful to be able to get code lens results on intermediate steps of the pipeline. E.g.,
[ 1..10 ]
|> List.map (fun i -> i * i)
|> List.map float
|> List.map (fun n -> n / 2.0)
|> List.map string
would display something like (if the comments below were actually code lens displays):
// int list
[ 1..10 ]
// int list
|> List.map (fun i -> i * i)
// float list
|> List.map float
// float list
|> List.map (fun n -> n / 2.0)
// string list
|> List.map string
Of course, in this trivial example, it's easy to follow the types "in your head". But when the pipelines involve more complex types like async<HttpContext option>
or lists of lists that you're flattening with List.collect id
, or other such complicated scenarios, then having code lens for each step of the pipeline would be handy instead of having to write:
let start = [1..10]
let step1 = start |> List.map (fun i -> i * i)
let step2 = step1 |> List.map float
// ... etc.
UPDATE: as mentioned in a comment below, I'd much rather use linelens now for this than codelens. E.g., I'd like to see something like the following for the trivial example:
[ 1..10 ] // int list
|> List.map (fun i -> i * i) // int list
|> List.map float // float list
|> List.map (fun n -> n / 2.0) // float list
|> List.map string // string list
With linelens, the drawback that @czifro mentions below would be almost entirely eliminated. (In some cases with long pipeline steps or types, the line lens might cause that one line to wrap, so there would be some cases where it could still increase the visual length of the file).