Skip to content

Instantly share code, notes, and snippets.

View bugaevc's full-sized avatar

Sergey Bugaev bugaevc

View GitHub Profile
#include <stdio.h>
#include <type_traits>
#include <utility>
#include <new>
template<typename T>
void forget1(T &&value) {
union Forget {
~Forget() { }
typename std::remove_reference<T>::type t;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bugaevc
bugaevc / ConcurrentFlow.kt
Created September 22, 2021 17:34
A sketch of ConcurrentFlow design
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.collectIndexed
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.Semaphore
import java.util.*
@bugaevc
bugaevc / DAnd.lean
Last active January 31, 2025 19:46
Dependent and connective
import Lean
/--
`(h : a) ∧ b`, the "dependent and" connective. This is a conjunction
just like `And`, but to even state the right hand side proposition,
we need the left hand side to hold.
Due to proof irrelevance, this is not actually quite as dependent as
it might look.
-/
structure DAnd {a : Prop} (b : a → Prop) : Prop where
class Arrow (A : Type u → Type u → Type w) where
comp (outer : A β γ) (inner : A α β) : A α γ
ofFunction : (α → β) → A α β
mapFirst : A α β → A (α × γ) (β × γ)
instance : Arrow (· → ·) where
comp := Function.comp
ofFunction := id
mapFirst arrow | (a, g) => (arrow a, g)