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

Inline eval no longer capable of using "it" to reference the output of the previous inline #1577

Closed
gabrielbcn opened this issue Mar 14, 2021 · 5 comments · Fixed by #1603
Closed
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@gabrielbcn
Copy link

Obviously the inline code evaluation is amazing, but in previous versions I used to do this:

-- >>> example
-- >>> used it
-- >>> fresh it
-- \a. \x. (\y. a) x b
-- ["a","b","x","y"]
-- "c"

So I would use it to refer to the previous output, the same as in a ghci session,

Now the following happens:

-- >>> example
-- >>> used it
-- >>> fresh it
-- \a. \x. (\y. a) x b
-- Variable not in scope: it :: Term
-- Variable not in scope: it :: [Var]

it can still be sorted in many ways, a very ugly one with variables:

-- >>> example
-- >>> it1 = example
-- >>> used it1
-- >>> it2 = used it1
-- >>> fresh it2
-- \a. \x. (\y. a) x b
-- ["a","b","x","y"]
-- "c"

But it is really a pity because removes the versatility of it that just brings the previous output whatever it was.

Any chance to bring it back?

Thanks a lot

@gabrielbcn gabrielbcn changed the title Inline eval no longer using "it" to reference the output of the previous inline Inline eval no longer capable of using "it" to reference the output of the previous inline Mar 14, 2021
@jneira jneira transferred this issue from haskell/vscode-haskell Mar 15, 2021
@jneira jneira added component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Mar 15, 2021
@jneira
Copy link
Member

jneira commented Mar 15, 2021

hi, thanks for the bug report, I ve translated the issue to the haskell-language-server repo as it is responsive for handling the eval feature
//cc @tittoassini

@tittoassini
Copy link
Contributor

honestly, I wasn't aware that 'it' was ever supported :-)

@gabrielbcn
Copy link
Author

gabrielbcn commented Mar 20, 2021

Not only it was supported but it was extremely useful. :)

@tittoassini
Copy link
Contributor

I had a look, it is easy to add a:

it <- return e

after an expression 'e' is evaluated.

That's not quite what GHCi does. GHCi sets "it" to the result of "e" evaluation, not "e" itself.

So, for example:

import System.CPUTime
*Ide.Arguments System.CPUTime> getCPUTime
2330167000000
*Ide.Arguments System.CPUTime> it
2330167000000
*Ide.Arguments System.CPUTime> it + it
4660334000000

However, we would set "it" to "getCPUTime" itself and then we would get:

-- >>> import System.CPUTime
-- >>> getCPUTime
-- >>> it
-- >>> it + it
-- 25948208000000
-- 25953978000000
-- No instance for (Num (IO Integer)) arising from a use of ‘+’

Naturally, one could argue that is a more correct, or at least more consistent, behaviour.

If we wanted to do what GHCi does, we would need to check the type of the expression "e" and execute:

for a pure value:

it <- return e

for an IO a:

it <- a

What I don't get is how "it" might ever have been supported, maybe @pepeiborra can explain?

@jneira
Copy link
Member

jneira commented Mar 22, 2021

@tittoassini hi! thanks to take a look, want to note there is a open pull request trying to fix the issue: #1603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants