This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let inline map (alg : ^Alg) (f : ^t -> ^s) (ts : ^ts) : ^ss = | |
(^Alg : (member Map : (^t -> ^s) * ^ts -> ^ss) (alg, f, ts)) | |
let inline filter (alg : ^Alg) (f : ^t -> bool) (ts : ^ts) : ^ts = | |
(^Alg : (member Filter : (^t -> bool) * ^ts -> ^ts) (alg, f, ts)) | |
let inline reduce (alg : ^Alg) (f : ^t -> ^t -> ^t) (ts : ^ts) : ^t = | |
(^Alg : (member Reduce : (^t -> ^t -> ^t) * ^ts -> ^t) (alg, f, ts)) | |
// type signature is unreadable, machine consumable only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Stream<'T> = ('T -> unit) -> unit | |
module Stream = | |
let inline groupWhile (pred : 'T -> bool) (source : Stream<'T>) : Stream<'T []> = | |
fun k -> | |
let ra = new ResizeArray<'T> () | |
let iter (t : 'T) = | |
if not <| pred t then | |
k <| ra.ToArray() | |
ra.Clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Repro | |
{ | |
[CompilationMapping(SourceConstructFlags.ObjectType)] | |
[Serializable] | |
public class Foo<T> | |
{ | |
internal T value; | |
public T Value | |
{ | |
get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo<'T>(bar (* add explicit type annotation to fix *), value : 'T) = | |
member __.Value = value | |
and Bar () as self = | |
let create (x : 'T) : Foo<'T> = | |
printfn "%O" typeof<'T> | |
new Foo<'T>(self, x) | |
member __.Create<'T>(x : 'T) : Foo<'T> = create x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stackless raise | |
let inline raise (e : exn) = (# "throw" e : ^T #) | |
let inline failwith ctor = raise << ctor | |
let inline failwithf ctor fmt = Printf.ksprintf (raise << ctor) fmt | |
// 1 | |
exception SomeOtherException of string | |
with override e.Message = e.Data0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FsPickler | |
let settings = new CustomPicklerRegistry("noStrongNames") | |
let nostrongnames = | |
{ | |
new ITypeNameConverter with | |
member __.ToDeserializedType tI = tI | |
member __.OfSerializedType (tI : TypeInfo) = | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo = | |
| A of value : int | |
| B of enabled : bool * somethingElse : bool | |
match B (false, false) with | |
| B(enabled = true) -> true | |
| B(somethingElse = x) -> x | |
| _ -> false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\usepackage{listings} | |
\usepackage{upquote} | |
\lstdefinelanguage{FSharp}% | |
{morekeywords={let, new, match, with, rec, open, module, namespace, type, of, member, % | |
and, for, while, true, false, in, do, begin, end, fun, function, return, yield, try, % | |
mutable, if, then, else, cloud, async, static, use, abstract, interface, inherit, finally }, | |
otherkeywords={ let!, return!, do!, yield!, use!, var, from, select, where, order, by }, | |
keywordstyle=\color{bluekeywords}, | |
sensitive=true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
type RetryPolicy = Policy of (int -> exn -> TimeSpan option) | |
/// retries given action based on given policy | |
let retryAsync (Policy p) (f : Async<'T>) = | |
let rec aux retries = | |
async { | |
let! result = Async.Catch f |
NewerOlder