Skip to content

ST monad trick #47

@mitchellwrosen

Description

@mitchellwrosen

Hi, I was just re-reading your excellent book and came across this warning:

There is nothing in the types to stop you from returning an IVar from runPar and
passing it to another call of runPar. This is a Very Bad Idea; don’t do it. The 
implementation of the Par monad assumes that IVars are created and used 
within the same runPar, and breaking this assumption could lead to a runtime 
error, deadlock, or worse.

The library could prevent you from doing this using qualified types in the same
way that the ST monad prevents you from returning an STRef from runST. This 
is planned for a future version.

Just curious, is this still meant to happen at some point?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions