Skip to content

Instantly share code, notes, and snippets.

View pelotom's full-sized avatar

Tom Crockett pelotom

  • Los Angeles, CA
View GitHub Profile
@OliverJAsh
OliverJAsh / foo.md
Created November 29, 2017 17:35
Tagged unions with unionize

Tagged unions are a way of saying "this data is any one of these values", and the tag is a property that discriminates the values. It enables some really powerful type system features, like exhaustive checking and control flow analysis.

Tagged unions also go by the name of: tagged unions, discriminated unions, algebraic data types (ADTs), and sum types. Just to confuse matters.

In many functional languages this is a really common pattern, like Haskell, Elm, PureScript, and Scala. So much so, they have their own native syntax.

For example, in Elm we can define a tagged union representing an anonymous or named user with:

// elm
@paf31
paf31 / 24days.md
Last active August 8, 2023 05:53
24 Days of PureScript

This blog post series has moved here.

You might also be interested in the 2016 version.

@ryboe
ryboe / bad_css
Last active April 25, 2024 16:18
Non-standard and Obsolete CSS Properties
OBSOLETE PREFIXES
-xv-interpret-as // -xv- and -o- are old Opera prefixes for the Presto
-xv-phonemes // engine. Opera switched to the Blink engine with
-xv-voice-balance // version 15. The current version is 34.
-xv-voice-duration
-xv-voice-pitch
-xv-voice-pitch-range
-xv-voice-rate
-xv-voice-stress
-xv-voice-volume
@mxswd
mxswd / TypeNats.swift
Last active December 12, 2016 19:24
Thanks @robrix and CodaFi_ for the discussion :D
// this is a playground
protocol Nat {
class func construct() -> Self
class func value() -> Int
}
struct Z : Nat {
static func construct() -> Z {
return Z()
}
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing