Skip to content

Global region #7

Closed
Closed

Description

@no-longer-on-githu-b

If this library adds a named region:

foreign import data Global :: *

Then you can use st :: ST Global as the effect of global mutations. For example:

main :: forall eff. Eff (st :: ST Global | eff) Unit
main = ...

Which would eliminate the need for REF. You could use existing local ST computations (forall r e. Eff (st :: ST r | e)) without runST if you already have an st :: ST Global effect, so I think there would be no issue with duplicate labels.

Activity

  1. hdgarrood commented on Nov 28, 2016

    @hdgarrood
    Contributor

    Most of the time, I think you want to use runST though, in order to have the compiler verify that mutation can't happen outside some particular scope.

  2. no-longer-on-githu-b commented on Nov 28, 2016

    @no-longer-on-githu-b
    Author

    Right, as long as you don't do both global and local mutations in a computation, you can still use runST to cast away the local ST region, and then use row polymorphism to add the global ST region.

  3. hdgarrood commented on Nov 28, 2016

    @hdgarrood
    Contributor

    Ok, good point. Maybe it's useful that STRef and Ref are different types, though, because then you can signal whether you expect to restrict the mutation to some local scope or not? That might not be clear from the rows, since you could universally quantify over the parameter to the ST effect. Although maybe that's a good thing, because then you could write code that works in both situations.

  4. no-longer-on-githu-b commented on Apr 3, 2017

    @no-longer-on-githu-b
    Author

    @hdgarrood Is this still an issue now psc supports duplicate labels? Can you have multiple st effects that work as expected?

  5. no-longer-on-githu-b commented on Apr 30, 2018

    @no-longer-on-githu-b
    Author

    We no longer use effect rows, so I'll close this issue as the situation is now different.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions