F-operator

  1. F-operator
  2. Documentation
    1. Shift/Reset - Dynamically scoped shift/reset
      1. reset
      2. shift
    2. BShift/BReset - Statically scoped shift/reset
      1. breset
      2. bshift
    3. Range
      1. range
      2. range
    4. Delimited Control
      1. prompt
      2. prompt0
      3. reset
      4. reset0
      5. control
      6. control-abort
      7. control0
      8. shift
      9. shift0
    5. Reflect/Reify - Monads
      1. define-unit
      2. define-bind
      3. reflect
      4. reify
    6. GShift/GReset - Generalized shift/reset
      1. greset
      2. gshift
      3. hr-stop
      4. hs-stop
      5. hr-prop
      6. hs-prop
      7. h-compose
      8. h-value
      9. h-datatype?
      10. h-cases
  3. Notes
  4. Requirements
  5. Bugs and Limitations
  6. Author
    1. Repository
  7. Version history
  8. License

Documentation

Delimited continuation operators.

Shift/Reset - Dynamically scoped shift/reset

(import shift-reset)

A "stuck on control" situation, a 'shift' without an enclosing 'reset', is an error.

reset

[syntax] (reset EXPRESSION ...)

Multiple value return version of (reset ...). The body will contain one or more instances of (shift ...).

shift

[syntax] (shift PC-TAG EXPRESSION)

Multiple value return version of (shift ...). Provide a value to the partial continuation using the form (PC-TAG <something> ...).

BShift/BReset - Statically scoped shift/reset

(import bshift-breset)

Invalid delimited continuations, what RC-TAG below represents, and stuck on control will generate an error

breset

[syntax] (breset RC-TAG EXPRESSION ...)

Multiple value return version of (breset ...). The body will contain one or more instances of (bshift RC-TAG ...).

bshift

[syntax] (bshift RC-TAG PC-TAG EXPRESSION)

Multiple value return version of (bshift ...). Provide a value to the partial continuation using the form (PC-TAG <something> ...).

Range

(import range)

range

[syntax] (range RC-TAG FROM VALUE STEP TO?)

The value of the delimited continuation RC-TAG ranges over the set of values specified by the state generation procedure suite. For use with (breset ...)

FROM
Zero argument procedure, returning the initial state
VALUE
Single argument procedure, of the state, returning the value of the state
STEP
Single argument procedure, of the state, returning the next state
TO?
Single argument procedure, of the state, returning {{#t) when the range is complete

range

[syntax] (range RC-TAG FROM [STEP] TO)

The value of the delimited continuation RC-TAG ranges over the number interval [FROM TO], by STEP. The increment is 1 when missing. For use with (breset ...).

Delimited Control

(import delimited-control)

Generalized shift/reset implementations of some control operators.

Within the scope of EXPR PP is bound to the reified partial continuation delimited by the enclosing (prompt/prompt0/reset/reset0 ...). Provide a value to the partial continuation using the form (PP <something>).

prompt

[syntax] (prompt EXPR)

prompt0

[syntax] (prompt0 EXPR)

reset

[syntax] (reset EXPR)

reset0

[syntax] (reset0 EXPR)

control

[syntax] (control PP EXPR)

control-abort

[syntax] (control-abort V)

control0

[syntax] (control0 PP EXPR)

shift

[syntax] (shift PP EXPR)

shift0

[syntax] (shift0 PP EXPR)

Reflect/Reify - Monads

(import reflect-reify)

The Monad example from Filinski, POPL '94

define-unit

[syntax] (define-unit KIND BODY ...)

Expands to (define (KIND-unit obj) BODY ...).

define-bind

[syntax] (define-bind KIND BODY ...)

Expands to (define (KIND-bind monad func) BODY ...).

reflect

[syntax] (reflect KIND MONAD)

Extract value from MONAD. Plays the role of Haskell '<-'.

reify

[syntax] (reify KIND EXPRESSION)

Return result of EXPRESSION as a monad.

GShift/GReset - Generalized shift/reset

(import gshift-greset)

The generalized shift and reset operator family from How to remove a dynamic prompt: static and dynamic delimited continuation operators are equally expressible

greset

[syntax] (greset HR E)

Reset parameterized by the H Reset procedure HR.

gshift

[syntax] (gshift HS F E)

Shift parameterized by the H Shift procedure HS.

hr-stop

[procedure] (hr-stop V)

H Reset Stop.

hs-stop

[procedure] (hs-stop V)

H Shift Stop

hr-prop

[procedure] (hr-prop V)

H Reset Propagate.

hs-prop

[procedure] (hs-prop V)

H Shift Propagate.

h-compose

[procedure] (h-compose F X)

Returns the composition of F and X as an h-datatype.

h-value

[procedure] (h-value V)

Returns the value of V as an h-datatype.

h-datatype?

[procedure] (h-datatype? OBJECT)

Is OBJECT an h-datatype?

h-cases

[syntax] (h-cases E ((F X) ON-h-EXPR) (V ON-V-EXPR))

Deconstructs the h-datatype E, binding F & X for an evaluation of the ON-h-EXPR and V for an evaluation of the ON-V-EXPR.

Notes

Requirements

box datatype miscmacros

test test-utils utf8 srfi-1 srfi-18

Bugs and Limitations

Author

Kon Lovett

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/F-operator

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Version history

4.1.3
Bit faster & larger.
4.1.2
Drop A Better API.
4.1.1
Some thread isolation. Multi-valued delimited-control.
4.1.0
Added delimited-control module.
4.0.0
CHICKEN 5 release.

License

Copyright (C) 2009-2023 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Does not supercede any restrictions found in the source code.