Skip to content

Instantly share code, notes, and snippets.

type Domain = interface end
type Projection<'R> =
abstract member source : Table<'R>
and Table<'R> = inherit Projection<'R>
and Table<'R, 'K> =
inherit Table<('R * 'K)>
abstract member row : 'R
abstract member key : 'K
type proj<'R> = Projection<'R>
@dsyme
dsyme / gist:b80086ce5c5a0dc1a9f7
Created July 18, 2015 09:41
type with optional unit of measure annotation and conversion functions
//custom type
type SomeType(v) = member x.V = v
[<AutoOpen>]
module Aux1 =
//custom type that can carry measure
[<MeasureAnnotatedAbbreviation>]
type SomeType<[<Measure>] 'm>(v) =
member x.V = v
namespace TODOList
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Client
[<JavaScript>]
module Code =
namespace TODOList
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Client
[<JavaScript>]
module Code =
[12:34:33] *** drs1005 would like to add you on Skype
Hi Василий Кириченко, I'd like to add you as a contact. This is Don Syme ***
[12:35:04] *** Василий Кириченко has shared contact details with drs1005. ***
[15:16:00] drs1005: hey got a moment?
[15:16:41] Василий Кириченко: hi, yep
[15:16:50] drs1005: I'd like to screen share, I'll call then we can do that.
[15:16:55] *** Call to Василий Кириченко ***
[15:17:39] Василий Кириченко: I don't have microphone here at work
[15:17:44] drs1005: ok, I'llscreen share
let inline min (array:_[]) =
let mutable acc = array.[0]
for i = 1 to array.Length - 1 do
let curr = array.[i]
if curr < acc then
acc <- curr
acc
let min2 (array:_[]) =
@dsyme
dsyme / gist:bfed2eed788c7ba58ccc
Last active July 4, 2022 22:23
Naked type aliases can add and name constraints
// This F# language suggestion wants a way to name collections of constraints:
// http://fslang.uservoice.com/forums/245727-f-language/suggestions/8509687-add-constraints-as-a-language-construct
//
// This is a type alias X<T> = T, so X<int> = int etc.
type X<'T> = 'T
// This is a type alias X<T> = T which adds a constraint
type WithStruct<'T when 'T : struct> = 'T
type Point =
struct
val X: float
val Y: float
new(x: float, y: float) = { X = x; Y = y }
new(x: float) = new Point(x, 3.0)
end
Point(3.0)
type Point =
struct
val X: float
[<DefaultValue>] val mutable Y: float
new(x: float) = { X = x }
end
let mutable p = Point(3.0)
p.Y <- 4.0
type Animal() = class end
type Dog() = inherit Animal()
let feed (animals: seq<Animal>) = ()
feed [ Dog(); Animal() ]