Loving data with F#

Post on 03-Jul-2015

65 views 0 download

description

Dive into F# type providers infrastructure

Transcript of Loving data with F#

Partners:

Valdis Iļjučonoks

Technical Fellow, Software Architect

Visual Studio ALM evangelist

Microsoft MVP

http://www.tech-fellow.net | @tech_fellow

Geta AS, Tech Fellow Consulting, Latvian .Net UG

valdis.iljuconoks@outlook.com

Loving data with F#

Valdis Iļjučonoks

There are three kinds of lies: lies,damned lies, and statistics.

-- Benjamin Disraeli

Information rich programming

Bring data source closer to program

Barrier to include data sources: Need to represent data as types, properties and methods

Generated code must be replaced every time service reference is adjusted

Type Providers

From 1k feet: Compile-time type provider

Erased or generated types approach

Data set schema as type info source

Driven by F# team and community

DbmlFileEdmxFile

ODataServiceSqlDataConnectionSqlEntityConnection

WsdlServiceAppSettings

ExcelGraph

MachineManagement

MathRegexXamlXrm

ApiaryCsv

FreebaseJson

WorldBankXml

DGMLWordCsv

DataStoreHadoop/Hive/Hdfs

HelloWorldManagement

MiniCvsXrm

FunScript…

{Demo image}

Json Provider

WorldBank Provider

Xml Provider

OData Service Provider

Is it worth to develop custom provider?

Is schema available?

Will provider have enough usage it’s worthwhile to write?

Will schema change during coding?

Will it change during program execution?

Authoring TypeProvider

Uses F# Code Quotations

AddMember()

AddMemberDelayed()

let staticProp = ProvidedProperty(propertyName = "StaticProperty",propertyType = typeof<string>,IsStatic = true,GetterCode = (fun args -> <@@ "Hello!" @@>))

staticProp.AddXmlDocDelayed(fun () -> "This is a static property")

t.AddMember staticProp

let t = ProvidedTypeDefinition(thisAssembly,namespaceName,"Type" + string n,baseType = Some typeof<obj>)

Type Providers

Bring data source closer to program

Feedback

Partners: