Skip to content

Instantly share code, notes, and snippets.

View eiriktsarpalis's full-sized avatar
🌴
On vacation

Eirik Tsarpalis eiriktsarpalis

🌴
On vacation
View GitHub Profile
open System
type StringToExnClass = StringToExnClass with
static member StringToExn (_: ArgumentNullException) = fun (s: string) -> ArgumentNullException s
static member StringToExn (_: AccessViolationException) = fun (s: string) -> AccessViolationException s
static member StringToExn (_: ArrayTypeMismatchException) = fun (s: string) -> ArrayTypeMismatchException s
// etc (need to wrap all relevant types)
let inline iStringToExn (a: ^a, b: ^b) =
((^a or ^b) : (static member StringToExn: ^b -> (string -> ^b)) b)
@palladin
palladin / gist:2634310
Created May 8, 2012 11:17
Scrap Your Boilerplate (with class)
// http://homepages.cwi.nl/~ralf/syb3/
let inline gmap f g (x : ^R) : ^R = (f ? (g) <- x)
type Data = Data with
static member inline ($)(f : ^F, x : ^A) = gmap Data f x
static member inline (?<-)(Data, f, x : int) = x
static member inline (?<-)(Data, f, x : string) = x
static member inline (?<-)(Data, f, x : bool) = x