Skip to content

Instantly share code, notes, and snippets.

Avatar
🦅
Swifting

Harlan Haskins harlanhaskins

🦅
Swifting
View GitHub Profile
@harlanhaskins
harlanhaskins / swift-format.swift
Created Oct 26, 2017
Simple Swift Formatter using SwiftSyntax
View swift-format.swift
import Foundation
import SwiftSyntax
func main() throws {
guard CommandLine.arguments.count > 1 else {
print("usage: swift-format [file]")
exit(-1)
}
let url = URL(fileURLWithPath: CommandLine.arguments[1])
View typed-lambda-calculus.v
Require Import String Arith List Bool Ascii.
Scheme Equality for string.
(*
* The Simply-Typed Lambda Calculus
*)
(*
* Two base types:
* - Integers (natural numbers)
View option_monad.v
Definition bind_option (A: Type) (B: Type) (opt: option A) (f: A -> option B): option B :=
match opt with
| Some v => f v
| None => None
end.
Definition return_option (A: Type) (a: A) := Some a.
(* return a >>= f = f a *)
Theorem left_identity_option A B a f:
@harlanhaskins
harlanhaskins / fix-calendar.swift
Created Aug 28, 2017
Fixes TigerCenter Calendars on the macOS calendar app
View fix-calendar.swift
#!/usr/bin/env swift
import EventKit
let eventStore = EKEventStore()
extension String: Error {}
func deleteBadEvents(calendarName: String) throws {
// Make dates for Fall Semester 2017 before exams
View spongebobify.rs
use std::env;
fn print_spongebob(vals: &[String]) {
let statement = vals.join(" ");
let mut lower = true;
for c in statement.chars() {
let new_c = if lower { c.to_lowercase().next() }
else { c.to_uppercase().next() };
if let Some(c) = new_c {
print!("{}", c);
View ARC.md

Automatic Reference Counting

Previously, Trill used the TinyGC garbage collector to manage memory allocated by indirect types. This garbage collector, though able to clean up these heap structures, does not afford the ability to introspect a data structure for its references, which is necessary to implement Copy on Write. As such, we have elected to move to an Automatic Reference Counting model for automatically managing the allocation of indirect types in the Trill language.

What is ARC?

@harlanhaskins
harlanhaskins / interface.swift
Last active Mar 2, 2017
A "Generated Interface" of everything Trill imports from C.
View interface.swift
// <none>:2:18
let __llvm__: Int
// <none>:3:19
let __clang__: Int
// <none>:4:25
let __clang_major__: Int
// <none>:5:25
View gist:36eafa7f717fb2709ae5b962977d4b40
(var_assign_decl <none>:2:18 kind="global" modifiers="implicit" mutable=false name="__llvm__" type="Int"
(num_expr <none>:2:18 raw="1" type="Int" value=1))
(var_assign_decl <none>:3:19 kind="global" modifiers="implicit" mutable=false name="__clang__" type="Int"
(num_expr <none>:3:19 raw="1" type="Int" value=1))
(var_assign_decl <none>:4:25 kind="global" modifiers="implicit" mutable=false name="__clang_major__" type="Int"
(num_expr <none>:4:25 raw="3" type="Int" value=3))
(var_assign_decl <none>:5:25 kind="global" modifiers="implicit" mutable=false name="__clang_minor__" type="Int"
(num_expr <none>:5:25 raw="9" type="Int" value=9))
(var_assign_decl <none>:6:30 kind="global" modifiers="implicit" mutable=false name="__clang_patchlevel__" type="Int"
(num_expr <none>:6:30 raw="1" type="Int" value=1))
View cllvm.pc
Name: cllvm
Description: The llvm library
Version: 3.9.1
Libs: -L/usr/local/Cellar/llvm/3.9.1/lib -lLLVMLTO -lLLVMObjCARCOpts -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMDebugInfoDWARF -lLLVMGlobalISel -lLLVMCoverage -lLLVMTableGen -lLLVMOrcJIT -lLLVMMIRParser -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUUtils -lLLVMObjectYAML -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMLibDriver -lLLVMOption -lLLVMLineEditor -lLLVMPasses -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser
View swiftpm-c++.md
You can’t perform that action at this time.