This file contains hidden or 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
// Mimic type classes with additional param | |
type 'a Num = { | |
zero: 'a | |
add: 'a -> 'a -> 'a | |
mult: 'a -> 'a -> 'a | |
fromInteger: int -> 'a } | |
let intNum = { | |
zero = 0 |
This file contains hidden or 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
module BuilderExample | |
open System | |
//Example: nullable { ... } with combining functionality | |
type NullableBuilder() = | |
let hasValue (a:Nullable<'a>) = a.HasValue | |
member t.Return(x) = Nullable(x) | |
member t.Bind(x, rest) = | |
match hasValue x with |
This file contains hidden or 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
//A small sample how to use F# 3.0 Entity Framework (EF) Type Provider. Visual Studio 11 Beta (and Northwind sample database) needed. | |
(* | |
#r "System.Data.Entity.dll" | |
#r "FSharp.Data.TypeProviders.dll" | |
*) | |
open System | |
open Microsoft.FSharp.Data.TypeProviders | |
module Queries = | |
This file contains hidden or 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
(* | |
You can use numeric literals, constant expressions and operator overloading to make your own arithmetics. Useful in DSL languages. | |
With NumericLiterals, you can use any of Q, R, Z, I, N, G. | |
Basic syntax: [Number][Letter] will forward the call to the type NumericLiteral[Letter] to FromInt32 [Number] (or FromInt64 or FromString...) | |
*) | |
//----------------------------------------------------- | |
//First example: | |
module NumericLiteralN = |
This file contains hidden or 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
#I @"C:\Tools\System.Reactive" | |
#r "System.Core.dll" | |
#r "System.Reactive.dll" | |
type observable<'a> = System.Collections.Generic.IObservable<'a> | |
type observer<'a> = System.Collections.Generic.IObserver<'a> | |
module Observable = | |
open System | |
open System.Linq |
This file contains hidden or 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
//#r "Microsoft.TeamFoundation.Client" | |
//#r "Microsoft.TeamFoundation.VersionControl.Client" | |
//#r "Microsoft.TeamFoundation.VersionControl.Common" | |
open Microsoft.TeamFoundation.Client | |
open Microsoft.TeamFoundation.VersionControl.Client | |
let tfsCheckOut filename = | |
let workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo filename | |
let workspace = RegisteredTfsConnections.GetProjectCollections().First() | |
|> TfsTeamProjectCollectionFactory.GetTeamProjectCollection |
This file contains hidden or 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
// Rx 1.0: | |
//#r "System.CoreEx" //for interactive and scripts | |
//#r "System.Reactive.dll" | |
//open System | |
//open System.Collections.Generic | |
//Rx 2.1: | |
#r "System.ComponentModel.Composition.dll" | |
#r "../packages/Rx-Interfaces.2.1.30214.0/lib/Net45/System.Reactive.Interfaces.dll" | |
#r "../packages/Rx-Core.2.1.30214.0/lib/Net45/System.Reactive.Core.dll" |
This file contains hidden or 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
//#r "System.Xml.dll" //for scripts or interactive | |
//#r "System.Xml.Linq.dll" | |
open System | |
open System.Xml.Linq | |
open System.IO | |
let getFiles = Directory.GetFiles("c:\\projects\\", "*.csproj", SearchOption.AllDirectories) | |
|> Array.toSeq | |
let getProjectInfo (fname:string) = |
This file contains hidden or 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
//#r "System.Runtime.Serialization" | |
//#r "FSharp.PowerPack" | |
open Microsoft.FSharp.Control.WebExtensions | |
open System | |
open System.Runtime.Serialization | |
open System.Runtime.Serialization.Json | |
open System.Net | |
open System.IO |
This file contains hidden or 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
//View codebehind | |
using System.Windows.Controls; | |
namespace HelloApp | |
{ | |
public partial class MainPage : UserControl | |
{ | |
public MainPage() | |
{ | |
// Required to initialize variables |