SlideShare a Scribd company logo
1 of 14
F# R TYPE
PROVIDER
Howard Mansell
6th September 2012
DISCLAIMER
F# R TYPE PROVIDER
 F# vs. R
 What are Type Providers?
 The R Provider
 Challenges
 Type Provider Growing Pains
 Was it worth it?
F# VS R

F#                                   R
 Functional + OO                     Functional-ish + Crazy-OO
 Compiled                            Interpreted
 Statically typed                    Dynamically typed
 OK for Exploratory Analysis         Strong for Exploratory Analysis
 Well-suited for building systems    Unsuitable for building systems
 Weak math/stats libraries           Strong stats libraries
 Basic visualization tools           Rich visualization tools
 Good for data acquisition           Poor for data acquisition
 Good for data processing            Decent for data processing
 Scalable                            Not particularly scalable
MIXING THEM
 WHY?
   Functionality from .NET libraries
   Data acquisition & transformation in F#
   Stats/graphics functionality from R libraries
   Build robust systems

 HOW?
   RDotNet provides .NET OO wrapper around R.DLL (in-process)
   RCOM provides cross-process access to R session via DCOM
   Rserve provides client-server socket-server access to R session
F# TYPE PROVIDERS
 A mechanism for “dynamically” providing types to the IDE +
  compiler
 Provided at compile/edit time, based on:
    Static parameters (in code)
    Access to external resources (database, WSDL, odata)

 Downstream code is then statically typed
 Good Intellisense experience
 Code fragments are generated at compile-time and injected
    “Schema” baked into client code

 Addresses a significant issue that drives people to dynamic
  languages
TYPE PROVIDERS VS CODE GEN
 Generally equivalent, except…
 Some problems don‟t scale with codegen (e.g. Freebase provider)
 Simpler process-wise (no additional tool to know/run)
 Uniform mechanism for access
 Somewhat simpler/less error-prone to write type provider
THE R PROVIDER
 Type Providers can be used for inter-language interop / meta-
  programming
 The “external resource”/schema in this case is the R environment
 Make R packages available as .NET namespaces
 Make R functions & values available as .NET members
 Uses RDotNet
    Lightweight, in-process
    Results kept in R environment unless explicitly marshaled back
    Objects can be explicitly saved and loaded into a real R session if desired.

 Available at
  http://github.com/BlueMountainCapital/FSharpRProvider
CHALLENGES
 How do we bridge dynamic <-> static typing?
 Dynamic typing basically just has one static type – Any/Obj/…
 .NET-base statically-typed languages still have a dynamic typing
  system
 Dynamic languages have lightweight syntax for dynamic method
  dispatch
 But R eshews dotted notation for method dispatch
 Do the obvious thing – use the “one static type”
    All arguments are of type object
    Results are of type RDotNet.SymbolicExpression – keeps result inside R
      engine
    Arguments can be native .NET types or SymbolicExpression
ARGUMENT PASSING
CONVENTIONS
 R has named and positional passing styles
 R has … argument (params/varargs)
 R allows arguments to have default values
    Function will be invoked even if no value supplied and no default
    Make all arguments optional

 These map pretty well onto F# named/optional arguments
    Need to expose functions as static members.
    Always exposed as RProvider.packagename.R.functionname

 Exceptions:
    In R, … argument can come before named arguments.
    In R, … arguments can be passed using an identifying name.
ARGUMENT CONVERSION
 Obvious basic type conversions are built in:
    Seq<double> -> numeric vector
    Double -> numeric vector
    Etc.

 Lists can be constructed using R.list()
 How do we support implicit conversion of bespoke classes?
    E.g. we have our own .NET DataFrame type, should convert to R data.frame
    Avoid forking the Open Source project

 Support plug-ins via Managed Extensibility Framework
    Plug-ins can use the type provider to call R functions, or talk to REngine
      directly
RESULT CONVERSION
 Results always come back as SymbolicExpression
    RDotNet wrapper around the R C datatype SEXPREC

 RProvider adds a Value property as extension
    Returns the default .NET representation of the SymbolicExpression
    Obvious default conversions are built-in – can add/override using MEF plug-in

 We also add GetValue<„ResType> : unit -> „ResType
    Allows caller to specify the type they want
    Supports things like NumericVector->double when vector is length 1
    Can also augment/override using MEF plug-in
TYPE PROVIDER GROWING PAINS
 Type providers are an awesome idea
 Current implementation has some kinks:
    Cannot compile Type Provider while binary is in use by VS (VS keeps it
     locked)
    If Type Providers are dependent on other assemblies they may not get
     resolved
    Accessing slow external resources can slow down your machine
    Buggy type providers can crash the IDE or compiler
    Builds may fail because of machine configuration:
        E.g. you don‟t have R
        You don‟t have the same packages installed in R
        Best to put external resources or schema files in source control
WAS IT WORTH IT?
 Having integrated, slightly-type-safe access to R from F#
  interactive is extremely powerful.
 This problem can be solved using code generation
 Using the type provider is much more “fluid” – no process
 Issues from previous slide detract from that somewhat
 Type providers have lots of interesting applications outside data
  access:
    COM interop
    WinRT interop
    Intra-language meta-programming (if static parameters were more flexible)

More Related Content

What's hot

The D Programming Language - Why I love it!
The D Programming Language - Why I love it!The D Programming Language - Why I love it!
The D Programming Language - Why I love it!ryutenchi
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
A Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaA Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaTomer Gabel
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and ScalaFilip Krikava
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R PackagesRsquared Academy
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Beauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptBeauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptHendrik Ebbers
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaKatrien Verbert
 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavatasmarru
 
Structured web programming
Structured web programmingStructured web programming
Structured web programmingahfast
 
Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Kiran Jonnalagadda
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialAdonisDamian
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesJimmy Lai
 

What's hot (20)

Dart workshop
Dart workshopDart workshop
Dart workshop
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
D programming language
D programming languageD programming language
D programming language
 
The D Programming Language - Why I love it!
The D Programming Language - Why I love it!The D Programming Language - Why I love it!
The D Programming Language - Why I love it!
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Jena Programming
Jena ProgrammingJena Programming
Jena Programming
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
A Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaA Field Guide to DSL Design in Scala
A Field Guide to DSL Design in Scala
 
Perl Programming - 02 Regular Expression
Perl Programming - 02 Regular ExpressionPerl Programming - 02 Regular Expression
Perl Programming - 02 Regular Expression
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and Scala
 
Google Dart
Google DartGoogle Dart
Google Dart
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R Packages
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Beauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptBeauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScript
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPedia
 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
 
Structured web programming
Structured web programmingStructured web programming
Structured web programming
 
Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorial
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languages
 

Viewers also liked

Building Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersBuilding Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersAnthony Brown
 
Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?Anthony Brown
 
Streaming ETL With Akka.NET
Streaming ETL With Akka.NETStreaming ETL With Akka.NET
Streaming ETL With Akka.NETpetabridge
 
Building applications with akka.net
Building applications with akka.netBuilding applications with akka.net
Building applications with akka.netAnthony Brown
 
Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Anthony Brown
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!David Hoerster
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Sergey Tihon
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetDavid Hoerster
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleansBill Tulloch
 
Data Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAMLData Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAMLPaco Nathan
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented ProgrammingScott Wlaschin
 

Viewers also liked (13)

MBrace: Cloud Computing with F#
MBrace: Cloud Computing with F#MBrace: Cloud Computing with F#
MBrace: Cloud Computing with F#
 
Building Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersBuilding Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software Developers
 
Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?
 
Drm and the web
Drm and the webDrm and the web
Drm and the web
 
Streaming ETL With Akka.NET
Streaming ETL With Akka.NETStreaming ETL With Akka.NET
Streaming ETL With Akka.NET
 
Building applications with akka.net
Building applications with akka.netBuilding applications with akka.net
Building applications with akka.net
 
Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnet
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
 
Data Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAMLData Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAML
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 

Similar to F# Type Provider for R Statistical Platform

Data Science - Part II - Working with R & R studio
Data Science - Part II -  Working with R & R studioData Science - Part II -  Working with R & R studio
Data Science - Part II - Working with R & R studioDerek Kane
 
Reproducible research (and literate programming) in R
Reproducible research (and literate programming) in RReproducible research (and literate programming) in R
Reproducible research (and literate programming) in Rliz__is
 
Consuming Data with F# Type Providers
Consuming Data with F# Type ProvidersConsuming Data with F# Type Providers
Consuming Data with F# Type ProvidersRachel Reese
 
R programming language
R programming languageR programming language
R programming languageKeerti Verma
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific LanguagesMarkus Voelter
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchAndrew Lowe
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
APIs And SDKs  Breaking Into And Succeeding In A Specialty MarketAPIs And SDKs  Breaking Into And Succeeding In A Specialty Market
APIs And SDKs Breaking Into And Succeeding In A Specialty MarketBill Dubie
 
R as supporting tool for analytics and simulation
R as supporting tool for analytics and simulationR as supporting tool for analytics and simulation
R as supporting tool for analytics and simulationAlvaro Gil
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programminghemasri56
 
JetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific LanguagesJetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific LanguagesOscar Rodriguez
 
Evolutionary Design Solid
Evolutionary Design SolidEvolutionary Design Solid
Evolutionary Design SolidSai Venkat
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
 
Chapter One
Chapter OneChapter One
Chapter Onebolovv
 
Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalJerin John
 
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...PROIDEA
 

Similar to F# Type Provider for R Statistical Platform (20)

Data Science - Part II - Working with R & R studio
Data Science - Part II -  Working with R & R studioData Science - Part II -  Working with R & R studio
Data Science - Part II - Working with R & R studio
 
Reproducible research (and literate programming) in R
Reproducible research (and literate programming) in RReproducible research (and literate programming) in R
Reproducible research (and literate programming) in R
 
Consuming Data with F# Type Providers
Consuming Data with F# Type ProvidersConsuming Data with F# Type Providers
Consuming Data with F# Type Providers
 
R programming language
R programming languageR programming language
R programming language
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific Languages
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible research
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
APIs And SDKs  Breaking Into And Succeeding In A Specialty MarketAPIs And SDKs  Breaking Into And Succeeding In A Specialty Market
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
 
R as supporting tool for analytics and simulation
R as supporting tool for analytics and simulationR as supporting tool for analytics and simulation
R as supporting tool for analytics and simulation
 
R programming Language
R programming LanguageR programming Language
R programming Language
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
JetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific LanguagesJetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific Languages
 
Evolutionary Design Solid
Evolutionary Design SolidEvolutionary Design Solid
Evolutionary Design Solid
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
Evolutionary Design Solid
Evolutionary Design SolidEvolutionary Design Solid
Evolutionary Design Solid
 
Chapter One
Chapter OneChapter One
Chapter One
 
R programming
R programmingR programming
R programming
 
Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_final
 
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
 

Recently uploaded

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

F# Type Provider for R Statistical Platform

  • 1. F# R TYPE PROVIDER Howard Mansell 6th September 2012
  • 3. F# R TYPE PROVIDER  F# vs. R  What are Type Providers?  The R Provider  Challenges  Type Provider Growing Pains  Was it worth it?
  • 4. F# VS R F# R  Functional + OO  Functional-ish + Crazy-OO  Compiled  Interpreted  Statically typed  Dynamically typed  OK for Exploratory Analysis  Strong for Exploratory Analysis  Well-suited for building systems  Unsuitable for building systems  Weak math/stats libraries  Strong stats libraries  Basic visualization tools  Rich visualization tools  Good for data acquisition  Poor for data acquisition  Good for data processing  Decent for data processing  Scalable  Not particularly scalable
  • 5. MIXING THEM  WHY?  Functionality from .NET libraries  Data acquisition & transformation in F#  Stats/graphics functionality from R libraries  Build robust systems  HOW?  RDotNet provides .NET OO wrapper around R.DLL (in-process)  RCOM provides cross-process access to R session via DCOM  Rserve provides client-server socket-server access to R session
  • 6. F# TYPE PROVIDERS  A mechanism for “dynamically” providing types to the IDE + compiler  Provided at compile/edit time, based on:  Static parameters (in code)  Access to external resources (database, WSDL, odata)  Downstream code is then statically typed  Good Intellisense experience  Code fragments are generated at compile-time and injected  “Schema” baked into client code  Addresses a significant issue that drives people to dynamic languages
  • 7. TYPE PROVIDERS VS CODE GEN  Generally equivalent, except…  Some problems don‟t scale with codegen (e.g. Freebase provider)  Simpler process-wise (no additional tool to know/run)  Uniform mechanism for access  Somewhat simpler/less error-prone to write type provider
  • 8. THE R PROVIDER  Type Providers can be used for inter-language interop / meta- programming  The “external resource”/schema in this case is the R environment  Make R packages available as .NET namespaces  Make R functions & values available as .NET members  Uses RDotNet  Lightweight, in-process  Results kept in R environment unless explicitly marshaled back  Objects can be explicitly saved and loaded into a real R session if desired.  Available at http://github.com/BlueMountainCapital/FSharpRProvider
  • 9. CHALLENGES  How do we bridge dynamic <-> static typing?  Dynamic typing basically just has one static type – Any/Obj/…  .NET-base statically-typed languages still have a dynamic typing system  Dynamic languages have lightweight syntax for dynamic method dispatch  But R eshews dotted notation for method dispatch  Do the obvious thing – use the “one static type”  All arguments are of type object  Results are of type RDotNet.SymbolicExpression – keeps result inside R engine  Arguments can be native .NET types or SymbolicExpression
  • 10. ARGUMENT PASSING CONVENTIONS  R has named and positional passing styles  R has … argument (params/varargs)  R allows arguments to have default values  Function will be invoked even if no value supplied and no default  Make all arguments optional  These map pretty well onto F# named/optional arguments  Need to expose functions as static members.  Always exposed as RProvider.packagename.R.functionname  Exceptions:  In R, … argument can come before named arguments.  In R, … arguments can be passed using an identifying name.
  • 11. ARGUMENT CONVERSION  Obvious basic type conversions are built in:  Seq<double> -> numeric vector  Double -> numeric vector  Etc.  Lists can be constructed using R.list()  How do we support implicit conversion of bespoke classes?  E.g. we have our own .NET DataFrame type, should convert to R data.frame  Avoid forking the Open Source project  Support plug-ins via Managed Extensibility Framework  Plug-ins can use the type provider to call R functions, or talk to REngine directly
  • 12. RESULT CONVERSION  Results always come back as SymbolicExpression  RDotNet wrapper around the R C datatype SEXPREC  RProvider adds a Value property as extension  Returns the default .NET representation of the SymbolicExpression  Obvious default conversions are built-in – can add/override using MEF plug-in  We also add GetValue<„ResType> : unit -> „ResType  Allows caller to specify the type they want  Supports things like NumericVector->double when vector is length 1  Can also augment/override using MEF plug-in
  • 13. TYPE PROVIDER GROWING PAINS  Type providers are an awesome idea  Current implementation has some kinks:  Cannot compile Type Provider while binary is in use by VS (VS keeps it locked)  If Type Providers are dependent on other assemblies they may not get resolved  Accessing slow external resources can slow down your machine  Buggy type providers can crash the IDE or compiler  Builds may fail because of machine configuration:  E.g. you don‟t have R  You don‟t have the same packages installed in R  Best to put external resources or schema files in source control
  • 14. WAS IT WORTH IT?  Having integrated, slightly-type-safe access to R from F# interactive is extremely powerful.  This problem can be solved using code generation  Using the type provider is much more “fluid” – no process  Issues from previous slide detract from that somewhat  Type providers have lots of interesting applications outside data access:  COM interop  WinRT interop  Intra-language meta-programming (if static parameters were more flexible)

Editor's Notes

  1. Demo: R-studio; 1+2x = 3xs = c(1,2,3) (both are vectors)Xs + xXs &gt; 1F = function(x) x + 1Look at fLook at cDf = data.frame(A=c(1,2,3), B=(c,4,5,6))Class(df)Unclass(df)Print(df)PrintPrint.data.frame
  2. Show RDotNet sample program.
  3. Examples: SQL provider, XML provider, Regex provider, CSV provider, Odata provider, file system provider
  4. Demo of F# type provider.#load script that provides getStockPrices as CSV (save files on disk)Call getStockPrices on MSFT and show results in visualizerCall R.log |&gt; R.diff on result – show resultlet data =[for t in tickers -&gt; t,getStockPrices t 255 |&gt;R.log|&gt;R.diff]Call R.data_frame on the resultShow pairs plotPick a pair – plot against each otherBuild lm.
  5. Take a look at the Rprovider.fs code
  6. Look at Rinterop.fs
  7. Show FactorVector and DataFrameConverter