Skip to content

Instantly share code, notes, and snippets.

:octocat:

Tim Kersey tkersey

:octocat:
Block or report user

Report or block tkersey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tkersey
tkersey / Co.swift
Created Oct 15, 2019 — forked from bkase/Co.swift
Co.swift seems to work. Read NaturalSubclass.swift for what doesn't work, Natural.swift for what seems to work, and Co_old.swift for where it breaks down
View Co.swift
import Bow
// This version of Co seems to work even thoug it's a bit gross to deal with Any
// Think of this as an example of how to deal with rank2 type polymorphism -- you only
// deal with Any in the constructor, even `runCo` has a generic interface.
// newtype Co w a = Co (forall r. w (a -> r) -> r)
public final class ForCo {}
public final class CoPartial<W: Comonad>: Kind<ForCo, W> {}
public typealias CoOf<W: Comonad, A> = Kind<CoPartial<W>, A>
@tkersey
tkersey / FunDay.hs
Created Sep 30, 2019 — forked from gelisam/FunDay.hs
a concrete use for FunDay, the right-adjoint of Day
View FunDay.hs
-- A concrete use case for the type which is to '(->)' as 'Day' is to '(,)'.
-- I call it "FunDay", but I don't know what its proper name is. I've been
-- trying to find a use for 'FunDay', and I think I've found a pretty neat one.
{-# LANGUAGE FlexibleContexts, FlexibleInstances, PolyKinds, RankNTypes, TypeSynonymInstances #-}
module Main where
import Test.DocTest
import Control.Monad.Except
import Control.Monad.Reader
@tkersey
tkersey / UIView+Tooltips.h
Created Sep 13, 2019 — forked from steventroughtonsmith/UIView+Tooltips.h
WIP tooltips for Mac Catalyst
View UIView+Tooltips.h
//
// UIView+Tooltips.h
// Crossword
//
// Created by Steven Troughton-Smith on 13/09/2019.
// Copyright © 2019 Steven Troughton-Smith. All rights reserved.
//
#import <UIKit/UIKit.h>
@tkersey
tkersey / kan.lean
Created Sep 8, 2019 — forked from skaslev/kan.lean
Kan extensions
View kan.lean
def ran (g h : TypeType) (α : Type) := Π β, (α → g β) → h β
def lan (g h : TypeType) (α : Type) := Σ β, (g β → α) × h β
def mapr {g h} {α β} (s : α → β) (x : ran g h α) : ran g h β :=
λ b t, x b (t ∘ s)
def mapl {g h} {α β} (s : α → β) (x : lan g h α) : lan g h β :=
⟨x.1, ⟨s ∘ x.2.1, x.2.2⟩⟩
attribute [reducible] id
@tkersey
tkersey / equipment.hs
Created Sep 7, 2019 — forked from sjoerdvisscher/equipment.hs
Proarrow equipment in Hask
View equipment.hs
{-# LANGUAGE RankNTypes, TypeOperators, GADTs, ScopedTypeVariables, KindSignatures, DataKinds, FlexibleInstances, FlexibleContexts #-}
module Equipment where
import Data.Profunctor
import qualified Data.Profunctor.Composition as P
import Data.Singletons.Prelude.List
-- +--f--+
-- | v |
-- p--@--q
@tkersey
tkersey / Bindings.swift
Created Jun 8, 2019 — forked from AliSoftware/Bindings.swift
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
View Bindings.swift
// This is a re-implementation of the @Binding and @State property wrappers from SwiftUI
// The only purpose of this code is to implement those wrappers myself just to understand how they work internally and why they are needed
// Re-implementing them myself has helped me understand the whole thing better
//: # A Binding is just something that encapsulates getter+setter to a property
@propertyDelegate
struct XBinding<Value> {
var value: Value {
get { return getValue() }
View TimeFormat.swift
public enum TimeFormat: String {
case twentyFourHour = "HH:mm"
case twelveHour = "h:mm a"
public init(_ locale: Locale = Locale.current) {
let is24Hour = DateFormatter
.dateFormat(fromTemplate: "j", options: 0, locale: locale)
.map { $0.contains("a") } ?? false
self = is24Hour ? .twentyFourHour : .twelveHour
}
View seemingly-impossible-swift-programs.swift
/*:
# Seemingly Impossible Swift Programs
*/
/*:
# 1.) Completely possible programs
*/
[1, 2, 3]
.allSatisfy { $0 >= 2 }
[1, 2, 3]
@tkersey
tkersey / ScrollDirection.swift
Created Dec 4, 2018
Use within scrollViewDidScroll
View ScrollDirection.swift
import UIKit
enum ScrollDirection: Int {
case up = -1
case none = 0
case down = 1
}
// MARK: - Determine
extension ScrollDirection {
@tkersey
tkersey / TrackerEmojis.md
Created Nov 14, 2018 — forked from mattmcneeney/TrackerEmojis.md
Emojis that are supported in Pivotal Tracker initials
View TrackerEmojis.md

Tracker emojis

A list of emojis that are allowed in Pivotal Tracker initials.

Emoji Unicode
\xE2\x9C\x82
\xE2\x9C\x85
\xE2\x9C\x88
\xE2\x9C\x89
You can’t perform that action at this time.