chickadee » F-operator

F-operator

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

(reset EXPRESSION ...)syntax

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

shift

(shift PC-TAG EXPRESSION)syntax

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

(breset RC-TAG EXPRESSION ...)syntax

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

bshift

(bshift RC-TAG PC-TAG EXPRESSION)syntax

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

Range

(import range)

range

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

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

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

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

(prompt EXPR)syntax

prompt0

(prompt0 EXPR)syntax

reset

(reset EXPR)syntax

reset0

(reset0 EXPR)syntax

control

(control PP EXPR)syntax

control-abort

(control-abort V)syntax

control0

(control0 PP EXPR)syntax

shift

(shift PP EXPR)syntax

shift0

(shift0 PP EXPR)syntax

Reflect/Reify - Monads

(import reflect-reify)

The Monad example from Filinski, POPL '94

define-unit

(define-unit KIND BODY ...)syntax

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

define-bind

(define-bind KIND BODY ...)syntax

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

reflect

(reflect KIND MONAD)syntax

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

reify

(reify KIND EXPRESSION)syntax

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

(greset HR E)syntax

Reset parameterized by the H Reset procedure HR.

gshift

(gshift HS F E)syntax

Shift parameterized by the H Shift procedure HS.

hr-stop

hr-stop Vprocedure

H Reset Stop.

hs-stop

hs-stop Vprocedure

H Shift Stop

hr-prop

hr-prop Vprocedure

H Reset Propagate.

hs-prop

hs-prop Vprocedure

H Shift Propagate.

h-compose

h-compose F Xprocedure

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

h-value

h-value Vprocedure

Returns the value of V as an h-datatype.

h-datatype?

h-datatype? OBJECTprocedure

Is OBJECT an h-datatype?

h-cases

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

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.

Contents »