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

Feature Request: FSI: Send Line, prefix with "it" #422

Open
kellerd opened this issue Apr 28, 2017 · 2 comments · May be fixed by #1614
Open

Feature Request: FSI: Send Line, prefix with "it" #422

kellerd opened this issue Apr 28, 2017 · 2 comments · May be fixed by #1614
Labels
enhancement Accepted suggestions that makes existing features better scripts Problems with .fsx files up for grabs Good first issues

Comments

@kellerd
Copy link

kellerd commented Apr 28, 2017

I was practicing a demo and thought of a simple feature that I think could be discussed.

Basically, as I'm giving a demo of F#, I want to show the intermediate states of the data, a line at a time. It would be useful, if the code looks like this:

Seq.initInfinite (fun n -> n * 2)
|> Seq.map (fun n -> n * n)
|> Seq.filter(fun n -> n % 3 = 0)
|> Seq.take 5
|> Seq.map Some
|> Seq.chunkBySize 5

That this feature would, send current line, if it starts with pipe, prefix with "it" and move to the next line, so I can see all the steps one by one with out having to select two lines, then three, then four, ect.

Example results:

Seq.initInfinite (fun n -> n * 2)
- ;;
val it : seq<int> = seq [0; 2; 4; 6; ...]
> it |> Seq.map (fun n -> n * n)
- ;;
val it : seq<int> = seq [0; 4; 16; 36; ...]
> it |> Seq.filter(fun n -> n % 3 = 0)
- ;;
val it : seq<int> = seq [0; 36; 144; 324; ...]
> it |> Seq.take 5
- ;;
val it : seq<int> = seq [0; 36; 144; 324; ...]
> it |> Seq.map Some
- ;;
val it : seq<int option> = seq [Some 0; Some 36; Some 144; Some 324; ...]
> it |> Seq.chunkBySize 5
- ;;
val it : seq<int option []> =
  seq [[|Some 0; Some 36; Some 144; Some 324; Some 576|]]
@rmunn
Copy link

rmunn commented May 2, 2017

In addition to demos, this could be useful for debugging as well, both at runtime ("Why am I getting the wrong result here?") and at compile time ("Why is the type of this expression not what I expected it to be?). I've sometimes broken out my pipelines into a series of let statements so that I could see their types in code lenses, but this feature would have also served my needs when I was getting a type error in a long pipeline.

But this just gave me an idea for another feature request: code lens on pipeline steps. I'll open a new issue to track that request.

@Krzysztof-Cieslak
Copy link
Member

My general problem with both suggestions is that it is not easy to implement correctly. It's fairly easy to do both features for such simple pipeline chains as your showing, but what if one of the functions in chain has it's own pipeline chain internally? What if we'll have multiple levels? I don't see easy way to make it robust enough, there is lot of edge cases that should be handled.

Maybe it could be done using FCS and manually going through AST. Something that may be worth investing... but not by me. I'd definitely accept PRs for any of those 2 features but it's not something of high priority for me personally.

@Krzysztof-Cieslak Krzysztof-Cieslak added the up for grabs Good first issues label Jul 11, 2017
@Krzysztof-Cieslak Krzysztof-Cieslak added scripts Problems with .fsx files enhancement Accepted suggestions that makes existing features better and removed feature request labels Dec 14, 2020
@joshuapassos joshuapassos linked a pull request Nov 9, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Accepted suggestions that makes existing features better scripts Problems with .fsx files up for grabs Good first issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants