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
// extremely fake example of decomposing multiple constructors | |
type Node = A of string | B of int | C of string * int | |
type Pair = Node * Node | |
type NodeList = Node list | |
type Structure = Simple of Pair | Complex of NodeList | |
let f = |
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
"e:\dtc\dtc.msbuild" (IntegrationTests target) (1) -> | |
(IntegrationTests target) -> | |
e:\dtc\dtc.msbuild(81,5): error : DTC.Tests.Web.TestWeb.TestPathAtRoot: System.ArgumentNullException : Value cannot be null. | |
e:\dtc\dtc.msbuild(81,5): error : Parameter name: str | |
e:\dtc\dtc.msbuild(81,5): error : at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str) | |
e:\dtc\dtc.msbuild(81,5): error : at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) | |
e:\dtc\dtc.msbuild(81,5): error : at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) | |
e:\dtc\dtc.msbuild(81,5): error : at System.Uri.ParseConfigFile(String file, IdnScopeFromConfig& idnStateConfig, IriParsingFromConfig& iriParsingConfig) | |
e:\dtc\dtc.msbuild(81,5): error : at System.Uri.GetConfig(UriIdnScope& idnScope, Boolean& i |
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 (|SeqEmpty|SeqCons|) (xs: 'a seq) = | |
if Seq.isEmpty xs then SeqEmpty | |
else SeqCons(Seq.head xs, Seq.skip 1 xs) | |
let rec CompareSeq (f : 'a -> 'a -> string option) (a:seq<'a>) (b:seq<'a>) = | |
match a, b with | |
| SeqEmpty, SeqEmpty -> None | |
| SeqCons(x,_), SeqEmpty -> Some <| sprintf "Sequence length differs, expecting %A" x | |
| SeqEmpty, SeqCons(x,_) -> Some <| sprintf "Sequence length differs, not expecting %A" x | |
| SeqCons(ax,arest), SeqCons(bx,brest) -> |
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 FParsec.Primitives | |
open FParsec.CharParsers | |
type Action = { | |
PlayerName: string | |
Kind: string | |
Money: float | |
} | |
type SeatInfo = { |
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
// example of generically defining a complex IComparable on an interface, using only that interface definition | |
type IFake = | |
abstract Path: string with get, set | |
abstract IsSection: bool with get, set | |
abstract ModifyDate: DateTime with get, set | |
abstract Content: DateTime with get, set | |
interface System.IComparable with | |
member this.CompareTo x = | |
let TIME_SKEW = 60.0 |
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 a = [(1,"hi");2,("there");3,("guys")] |> Map.ofList | |
let b = [(1,"hi");2,("there");4,("dudes")] |> Map.ofList | |
let in_map map k = Map.containsKey k map | |
let map_intersect m1 m2 = Map.partition (fun k _ -> in_map m1 k) m2 |> fst | |
let c = map_intersect a b |
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 TreeReader<'a> = { | |
Children: 'a -> 'a seq | |
StateForPath: string -> 'a | |
StateToNodeBasic: 'a -> NodeBasic | |
StateToNode: 'a -> Node | |
BasePath: string | |
BaseState: 'a | |
Settings: SyncSettings option | |
ReadTranslations: TranslationList | |
} |
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 Settings = string | |
type Actor<'a> = { State: 'a; Settings: Settings } | |
with member x.Action() = printfn "Fake %A" x.State | |
let Awesome(x:int, s)= { State = x; Settings = s } | |
let Terrible(y:string, s) = { State = y; Settings = s } | |
type Language = |
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 in comment! | |
let x = 12 | |
(* | |
and also | |
*) | |
let y = "Hooray!" |
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
// Given an ('a -> bool) list and an 'a list, generate a list | |
// containing any items that pass all of the functions | |
let FilterListByList filters = | |
let trueForAll n = List.forall (fun f -> f n) | |
let onFilterList n = trueForAll n filters | |
List.filter onFilterList | |
let FilterListByListOneLiner filters = | |
List.filter ( fun i -> List.forall ( fun f -> f i ) filters ) |