Skip to content

Instantly share code, notes, and snippets.

#lang racket
(require (for-syntax racket/function
syntax/apply-transformer)
syntax/parse/define)
(define-syntax ($expand stx)
(raise-syntax-error #f "illegal outside an ‘expand-inside’ form" stx))
(begin-for-syntax
#lang racket
(require (for-syntax racket/syntax)
syntax/parse/define
syntax/stx)
(begin-for-syntax
(define-syntax-class a/d*r
#:attributes [[a/d 1]]
#:description "a sequence of ‘a’s and ‘d’s followed by a single ‘r’"
#lang racket
(require (for-syntax racket/syntax
threading)
racket/contract
syntax/parse/define)
(define/contract (make-singleton name)
(-> symbol? any/c)
(struct singleton ()
#lang racket
(define/contract (syntax-armed? stx)
(-> syntax? boolean?)
(define (tainted? v)
(and (syntax? v) (syntax-tainted? v)))
(or (syntax-tainted? stx)
(match (syntax-e stx)
[(list* as ... b)
(or (ormap tainted? as) (tainted? b))]
#lang racket/base
;; ---------------------------------------------------------------------------------------------------
;; high-level definition context API
(module intdef racket/base
(require (prefix-in racket: racket/base)
racket/contract
racket/syntax
syntax/apply-transformer
#lang racket
(require syntax/parse/define "foods.rkt" (for-syntax "foods.rkt"))
(add-delicious-food! "pineapple")
(add-delicious-food! "sushi")
(add-delicious-food! "cheesecake")
(define-simple-macro (add-food-combinations! [fst:string ...]
[snd:string ...])
#:do [(for* ([fst-str (in-list (syntax->datum #'[fst ...]))]
#lang racket/base
(require (for-syntax racket/base
syntax/for-body)
benchmark
plot
racket/format
racket/generator
racket/match
racket/stream)
#lang racket/base
(require (for-syntax racket/base
racket/list
racket/match
syntax/kerncase)
syntax/parse/define)
(define-syntax (argument stx) (raise-syntax-error #f "cannot be used as an expression" stx))

Monads and delimited control are very closely related, so it isn’t too hard to understand them in terms of one another. From a monadic point of view, the big idea is that if you have the computation m >>= f, then f is m’s continuation. It’s the function that is called with m’s result to continue execution after m returns.

If you have a long chain of binds, the continuation is just the composition of all of them. So, for example, if you have

m >>= f >>= g >>= h

then the continuation of m is f >=> g >=> h. Likewise, the continuation of m >>= f is g >=> h.

@lexi-lambda
lexi-lambda / find-arrow-packages.rkt
Created April 12, 2020 19:16
A hacky script for scraping packages that use arrow notation from Hackage
#lang racket
(require db/base
db/sqlite3
json
net/url
racket/async-channel
threading)
(define WORKERS 6)