Skip to content

Instantly share code, notes, and snippets.

View Neftedollar's full-sized avatar
😎
whereing glasses

Roman Melnikov Neftedollar

😎
whereing glasses
View GitHub Profile
type ColumnSelector = { Name: string; ColumnName: string }
type RowSelector = { Name: string; RowName: string }
type SetValueArgs = { Name: string; RowName: string; ColumnName: string; Value: string }
type SetDefaultValueArgs = { Name: string; RowName: string; Value: string }
type Command =
| Create of string
| AddColumn of ColumnSelector
(*
WHAT'S GOING ON HERE?!
Sometimes you don't care about a particular type, you're interested in one field only, let's say `EntityId`.
Instead of using interface (which isn't even possible if don't own a type),
we can do structural typing in F# using SRTP and Active Patterns.
Active patterns are not required for this, but they do make code much easier to use.
*)
// So we have 2 types with field `EntityId: string`:
#if INTERACTIVE
#I @"C:\Tools\MongoDB-CSharp\MongoDB.Linq\bin\Debug"
#r "MongoDB.Driver.dll"
#r "MongoDB.Linq.dll"
#r "FSharp.PowerPack.Linq.dll"
#r "System.Core.dll"
#endif
open System
open MongoDB.Driver