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

Ref.read returns the old value after being written in a repl session #3803

Open
edwardw opened this issue Mar 6, 2020 · 1 comment
Open

Comments

@edwardw
Copy link

edwardw commented Mar 6, 2020

In a Purescript REPL, reading a Ref after being updated returns the wrong answer if one types the inputs one line a time:

PSCi, version 0.13.6
Type :? for help

> import Prelude 
> import Effect.Ref as Ref
> import Effect.Unsafe
> ref = unsafePerformEffect $ Ref.new 0
> unsafePerformEffect $ Ref.write 1 ref
unit

> unsafePerformEffect $ Ref.read ref
0

But it does behave as expected if using :paste:

> :paste
… unsafePerformEffect do
…   ref <- Ref.new 0
…   Ref.write 1 ref
…   Ref.read ref
… 
1

This is most bizarre.

@hdgarrood
Copy link
Contributor

This is to do with how the repl works, and not this library. Essentially, each time you enter a new command, the repl creates a module with all of the stuff you’ve entered, compiles it, and runs it.

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

No branches or pull requests

2 participants