Skip to content

Conversation

@berberman
Copy link
Collaborator

Closes #1577

#438 introduced an alternative way to evaluate expressions: we wrapped expressions with asPrint, and then used compileExpr to get the coerced result IO String. However, it broke functionality of it variable -- referencing the last evaluated result.

This PR restores the old eval plugin's behaviour: there is no special treatment for expressions anymore; instead, expressions are just statements, and we redirect the output of execStmt to a temporary file to get the same result as compileExpr.

Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@berberman
Copy link
Collaborator Author

All test cases on Windows are failing:

lexical error in string/character literal at character 'U'

Perhaps an encoding-related issue?

@jneira
Copy link
Member

jneira commented Mar 22, 2021

@berberman mmm, i think you will have to save the file using utf-8, not sure how being in a evaluated expression, see

let writeFileUTF8NoNewLineTranslation file txt =
withFile file WriteMode $ \h -> do
hSetEncoding h utf8
hSetNewlineMode h noNewlineTranslation
hPutStr h (T.unpack txt)

(maybe you will not need the newline thing)

There is a function in the extra package writeUtf8 but i guess maybe you cant use it in that context.

@berberman
Copy link
Collaborator Author

Never mind, I found it might be caused by the backslash was not escaped properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants