Skip to content

Instantly share code, notes, and snippets.

@lo48576
lo48576 / never-type-coercion.md
Last active December 7, 2017 13:54
Rust での発散と型推論とセミコロンあたりの挙動について、疑問と答えと経緯の調査。そのうちブログにまとめる予定の話のメモ。

発散と 型推論と セミコロン Rustにおける 疑問と答え #57577

雑なメモ。 そのうちフォーマットしてブログにまとめる予定。

内容は 2017-10-14 およびそれ以前の情報に基く。

更新

過去のこのファイルの内容にはいくらかのミスや古くなった内容などがあるため、内容を更新しつつブログに書き直した。 Rust での never type とセミコロン、型推論のルール変遷 - 何とは言わない天然水飲みたさ を参照されたい。

/*:
This is an implementation of Algorithm W, as found in [Principal Types for functional programs](http://web.cs.wpi.edu/~cs4536/c12/milner-damas_principal_types.pdf).
We'll start by defining literals and expressions:
*/
enum Literal {
case string(String)
case int(Int)
@yuzeh
yuzeh / LengauerTarjan.scala
Last active October 23, 2024 21:59
Lengauer-Tarjan Dominator Tree Algorithm
object LengauerTarjan {
// Implement these three yourself
def successors(v: Int): Iterable[Int] = ???
def predecessors(v: Int): Iterable[Int] = ???
def numNodes: Int = ???
// Lifted from "Modern Compiler Implementation in Java", 2nd ed. chapter 19.2
def computeDominatorTree(): Array[Int] = {
var N = 0
@CodaFi
CodaFi / AlgorithmW.swift
Last active July 28, 2024 10:04
A Swift Playground containing Martin Grabmüller's "Algorithm W Step-by-Step"
/// Playground - noun: a place where people can play
/// I am the very model of a modern Judgement General
//: # Algorithm W
//: In this playground we develop a complete implementation of the classic
//: algorithm W for Hindley-Milner polymorphic type inference in Swift.
//: ## Introduction
@chriseidhof
chriseidhof / parsers.swift
Last active December 28, 2020 04:36
Faster Parsers
//
// Operators.swift
// FastParsing
//
// Created by Chris Eidhof on 26/12/2016.
// Copyright © 2016 objc.io. All rights reserved.
//
// TODO: give appropriate credit. Many parts were stolen from SwiftParsec.
@steipete
steipete / ios-xcode-device-support.sh
Last active October 14, 2024 16:35
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@kongtomorrow
kongtomorrow / gist:9a8530528cac708a7b48
Created December 3, 2014 01:06
Swift options for use with -Xllvm
% swiftc -Xllvm -help-hidden /tmp/foo.swift
USAGE: swift (LLVM option parsing) [options]
OPTIONS:
-a9-754319-workaround - Enable workarounds for A9 HW bugs #754319
-a9-754320-workaround - Enable workarounds for A9 HW bugs #754320
-aarch64-use-tbi - Assume that top byte of an address is ignored
-agg-antidep-debugdiv=<int> - Debug control for aggressive anti-dep breaker
-agg-antidep-debugmod=<int> - Debug control for aggressive anti-dep breaker
-aggressive-ext-opt - Aggressive extension optimization