Skip to content

Instantly share code, notes, and snippets.

#lang racket/base
; Lock-free FIFO queues, loosely based on “Simple, Fast, and Practical
; Non-Blocking and Blocking Concurrent Queue Algorithms”.
(require racket/contract
racket/future
(only-in racket/unsafe/ops unsafe-struct*-cas!))
(provide queue?

With scoped effects, handlers must be a part of the program

It is seductive to imagine that effect handlers in an algebraic effect system are not part of the program itself but metalanguage-level folds over the program tree. And in traditional free-like formulations, this is in fact the case. The Eff monad represents the program tree, which has only two cases:

data Eff effs a where
  Pure :: a -> Eff effs a
  Op :: Op effs a -> (a -> Eff effs b) -> Eff effs b

data Op effs a where
@lexi-lambda
lexi-lambda / Matrix.agda
Last active November 17, 2020 02:26
Inductive n-tensor representation proof of concept in Agda
module Matrix where
open import Data.Fin as Fin using (Fin; zero; suc)
open import Data.List as List using (List; []; _∷_; product)
open import Data.Nat as Nat
open import Data.Nat.Properties as Nat
open import Data.Product as Prod
open import Data.Vec as Vec using (Vec; []; _∷_)
open import Level using (Level)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)