class Map<K, V> {
...
V getOrSignal(K key) {
if containsKey(key) {
return get(key);
} else {
MissingKeySignal signal = throw new MissingKeyException(this, key);
return switch signal {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;; Ported from the paper "Stream Fusion, to Completeness" (POPL 2017) | |
(struct staged-stream (init-function step-function)) | |
(struct staged-vec-stream-state (index-id vec-id)) | |
(define (staged-vec-stream vec-expr) | |
(define (init state-accepting-result-continuation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;; This module defines a Racket syntax formatter that uses pretty-expressive as | |
;; the underlying formatting engine. The formatter takes *syntax objects* as | |
;; input and produces a pretty-expressie document as output. Formatting occurs | |
;; in steps, similar to macro expansion: each step analyzes a syntax object and | |
;; returns a *partially formatted* syntax object, which consists of strings | |
;; interleaved with unformatted syntax objects representing the subforms of the | |
;; input object. Formatting begins with the outermost syntax object and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/generic) | |
(define-generics vable | |
(get-v vable)) | |
(struct a (v) | |
#:methods gen:vable | |
[(define (get-v a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is my attempt at translating the stream pipeline and transducer library I wrote for Racket | |
// into Effekt, using algebraic effects to model the actions of consuming and emitting values in a | |
// stream pipeline. The stream pipeline library I wrote is part of my package Rebellion, see its docs | |
// here: https://docs.racket-lang.org/rebellion/Streaming_Computations.html. The basics are that a | |
// stream pipeline combines an initial source (a lazy stream, sequence, or other similar object) and | |
// a terminal sink, called a *reducer*, along with any number of intermediate transformations called | |
// *transducers*. | |
type Option[A] { Present(value: A); Absent() } |
Mandatory APIs:
interface List {
size
add(x)
get(i)
set(i, x)
removeAt(i)
insert(i, x)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/contract/base) | |
(provide | |
(contract-out | |
[mutable-rb-tree-pict (-> mutable-rb-tree? pict?)])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
;; This is a "static continuation" system, which I developed as a foundation for building macros like | |
;; the following: | |
;; | |
;; - The guard, guard-match, and guard-define statement macros in rebellion/private/guarded-block | |
;; - A (parameterize! id expr) statement macro that sets a parameter for the rest of the block | |
;; - An (open! disposable-expr) expression macro that allocates a resource and closes it at the end of | |
;; the block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/generic | |
(prefix-in racket/list. racket/list) | |
racket/match | |
racket/stream | |
racket/struct | |
racket/unsafe/ops | |
(prefix-in racket/vector. racket/vector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(provide sdfn-register-id scalar-sdfn-register-id vec3-sdfn-register-id (struct-out sdfn-register)) | |
(require syntax/parse) | |
(struct sdfn-register (size offset initial-values) #:transparent) |
NewerOlder