Skip to content

Instantly share code, notes, and snippets.

View tkersey's full-sized avatar
👹

Tim Kersey tkersey

👹
View GitHub Profile
@tkersey
tkersey / ReducedReplayAsyncStream.swift
Created March 14, 2024 06:27 — forked from ABridoux/ReducedReplayAsyncStream.swift
An AsyncSequence that allows to be consumed several times. Returning the current state as specified in a reduce function
struct ReducedReplayAsyncStream<Element> {
typealias Reduce = (_ partialResult: inout Element, _ nextResult: Element) -> Void
private let storage: _Storage
private var originalStream: AsyncStream<Element>
init(
bufferingPolicy limit: AsyncStream<Element>.Continuation.BufferingPolicy = .unbounded,
initialResult: Element,
-- Yoneda --------------------------------------------------------------
newtype Yoneda f a = Yoneda { runYoneda :: forall b. ((a -> b) -> f b) }
instance Functor (Yoneda f) where
fmap f y = Yoneda (\ab -> runYoneda y (ab . f))
toYoneda :: Functor f => f a -> Yoneda f a
toYoneda fa = Yoneda (\f -> fmap f fa)
fromYoneda :: Yoneda f a -> f a
@tkersey
tkersey / algebraic-effects-series-4.md
Created June 30, 2023 22:33 — forked from yelouafi/algebraic-effects-series-4.md
Implementing Algebraic Effects and Handlers

Algebraic Effects in JavaScript part 4 - Implementing Algebraic Effects and Handlers

This is the final part of a series about Algebraic Effects and Handlers.

So we've come to the core topic. The reality is that we've already covered most of it in the previous parts. Especially, in the third part, where we saw delimited continuations at work.

@tkersey
tkersey / CoC.ml
Created February 25, 2023 22:50 — forked from Hirrolot/CoC.ml
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@tkersey
tkersey / youtube.md
Created January 28, 2023 19:15 — forked from bitsurgeon/youtube.md
Markdown cheatsheet for YouTube

Embed YouTube Video in Markdown File

  1. Markdown style
[![Watch the video](https://img.youtube.com/vi/nTQUwghvy5Q/default.jpg)](https://youtu.be/nTQUwghvy5Q)
  1. HTML style
<a href="http://www.youtube.com/watch?feature=player_embedded&v=nTQUwghvy5Q" target="_blank">
@tkersey
tkersey / HowTo use xcconfig or plist with SPM.md
Created November 30, 2022 15:39 — forked from 4np/HowTo use xcconfig or plist with SPM.md
How to use a .xcconfig file and a .plist with a Swift Package Manager based project.

How to use a .xcconfig file and a .plist file with SPM

Worth a read for some more context.

Create a Package.xcconfig file

Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:

/// Package.xcconfig
@tkersey
tkersey / Combinators.swift
Created November 28, 2022 15:41 — forked from danielt1263/Combinators.swift
A list of combinators
func apply<A, B>(fn: (A) -> B, a: A) -> B {
fn(a)
}
func bluebird<A, B, C>(fn1: (A) -> B, fn2: (C) -> A, c: C) -> B {
fn1(fn2(c))
}
func blackbird<A, B, C, D>(fn1: (C) -> D, fn2: (A, B) -> C, a: A, b: B) -> D {
@tkersey
tkersey / xcode-vim.markdown
Created November 16, 2022 16:40 — forked from gdavis/xcode-vim.markdown
Notes for working with Xcode VIM mode

Xcode VIM

This document is a scratchpad for helping me learn commonly used actions in Xcode's VIM mode.

Commands are case-sensitive. A command of N means pressing shift + n on the keyboard.

[Formatting is a WIP]


Normal Mode Commands

Basic Navigation

@tkersey
tkersey / Moore.hs
Created March 6, 2022 23:31 — forked from ekmett/Moore.hs
Moore for Less
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RankNTypes #-}
import Control.Applicative
import Control.Comonad
import Data.Bifunctor