Skip to content

Instantly share code, notes, and snippets.

@camoy
Created December 16, 2020 05:48
Show Gist options
  • Save camoy/9643b6e73e6e6fbeeb801245e1599d05 to your computer and use it in GitHub Desktop.
Save camoy/9643b6e73e6e6fbeeb801245e1599d05 to your computer and use it in GitHub Desktop.
#lang racket/base
(require racket/contract)
(define must-return/c
(make-contract
#:name 'must-return/c
#:late-neg-projection
(λ (blm)
(λ (f neg)
(λ args
(define finished? #f)
(dynamic-wind
void
(λ ()
(begin0
(apply f args)
(set! finished? #t)))
(λ ()
(unless finished?
(raise-blame-error blm
#:missing-party neg
f
"procedure did not return")))))))))
(define/contract (g f)
must-return/c
(f))
(let/cc k
(g (λ () (k 42))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment