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

Add break back to the language #3

Closed
elliottt opened this issue Jun 22, 2013 · 1 comment
Closed

Add break back to the language #3

elliottt opened this issue Jun 22, 2013 · 1 comment

Comments

@elliottt
Copy link
Contributor

As breakOut is considered unsafe in some contexts, e.g. in conjunction with a use of forever in the body of a tower task, it seems reasonable to consider this an effect to be tracked, rather than removing it from the language. If it's an effect, than it's still something that can be used by programmers, but restricted by API designers.

Defining an effect for break would yield a new signature for the breakOut function:

breakOut :: (CanBreak eff) => Ivory eff ()

Thus registering the requirement for a context that allows the breakOut function to be used. This has an added side-benefit of making it impossible to write functions where breakOut is used in a nonsensical position, as presumably only looping functions would introduce the CanBreak effect locally.

WIth this change to breakOut, the tower task loop example changes so that the argument that it will pass to forever has a very restricted context:

taskBody :: (outer `AllocsIn` s)
         => (forall inner. (inner `AllocsIn` s) => Ivory inner ())
         -> Ivory outer ()
taskBody body =
  do ...
     forever body

As you can see, the taskBody function takes an argument that only permits allocation effects, thus preventing uses of ret, and breakOut, as the new restrictive inner context will not permit them to be used.

@leepike
Copy link
Contributor

leepike commented Sep 11, 2013

Tracked by the type system now.

@leepike leepike closed this as completed Sep 11, 2013
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