0
Information-rich programming in                  F#                  Tomas Petricek, University of Cambridge              ...
The confusion of languages
The confusion of languages
What is a type provider?
DEMO: Accessing World BankComparing university enrollment rate in  Czech Republic and OECD countries
Problems with data accessData is not types with members Use dynamic languages?Need to know names of properties Use code ge...
Components of a type provider            Type provider    IDE                  CompilerIntelliSense for     Type-Check    ...
Research problemsMapping data sources to types  What is a type? What is a value?Types are provided on demand  Cannot gener...
Mapping data source to typesCountry  Indicator     Year
Research problemsMapping data sources to types  What is a type? What is a value?Types are provided on demand  Cannot gener...
Gamma, The ForgottenStandard typing judgmentsGamma on steroids            Γ = …,   WB.DataContext  WB.DataContext = Countr...
Research problemsMapping data sources to types  What is a type? What is a value?Types are provided on demand  Cannot gener...
DEMO: XML Type Provider  Working with XML data and  adapting to schema change
Related WorkCompile-time meta-programming Types generated eagerly, not on demandDependently typed languages Type-level com...
For more informationUpcoming technical report Don Syme, et al. Strongly-Typed Language Support for an Information-Rich Wor...
SummaryMismatch between data and types Type providers bridge the gap Development-time, compile-time & run-timeInteresting ...
Research problemsMapping data sources to types  What is a type? What is a value?Types are provided on demand  Cannot gener...
DEMO: FreeBase Type Provider    Working with chemistry data       and units of measure
Structure of a Simple Provider[<TypeProvider>]type SampleTypeProvider(config: TypeProviderConfig) =  inherit TypeProviderF...
Compile-Time vs. Run-timeType Provider      Runtime API      Provider                                     Accesses        ...
Compile-Time vs. Run-timeType Provider      Runtime API      Provider                                     Accesses        ...
Queries in F#Can be turned to quotations    query { for movie in netflix.Titles do            where (movie.Name.Contains(s...
Upcoming SlideShare
Loading in...5
×

Information-rich programming in F# (ML Workshop 2012)

543

Published on

We live in an information-rich world that provides huge opportunities for programmers to explore and create exciting applications. Traditionally, statically typed programming languages have not been aware of the data types that are implicitly available in the outer world such as the web, databases and semi-structured files. This tutorial presents the recent work on F# Type Providers - a language mechanism that enables a smooth integration of diverse data sources into an ML-style programming language. As a case study, we look at a type provider for accessing the world development indicators from the World Bank and we will discuss some intriguing research problems associated with mapping real-world data into an ML-style type system.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
543
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Information-rich programming in F# (ML Workshop 2012)"

  1. 1. Information-rich programming in F# Tomas Petricek, University of Cambridge Don Syme and the F# team, MicrosoftML Workshop (Copenhagen, 13 September, 2012)
  2. 2. The confusion of languages
  3. 3. The confusion of languages
  4. 4. What is a type provider?
  5. 5. DEMO: Accessing World BankComparing university enrollment rate in Czech Republic and OECD countries
  6. 6. Problems with data accessData is not types with members Use dynamic languages?Need to know names of properties Use code generation and static languages?Enormous scale of data sources Types need to be generated “on demand”
  7. 7. Components of a type provider Type provider IDE CompilerIntelliSense for Type-Check Compile usingProvided Types Provided Types Type Provider
  8. 8. Research problemsMapping data sources to types What is a type? What is a value?Types are provided on demand Cannot generate all indicator types at once!Representing data source properties as types Physical units, provenance, temporal propertiesAdapting to schema change Type soundness is relative w.r.t. data source changes
  9. 9. Mapping data source to typesCountry Indicator Year
  10. 10. Research problemsMapping data sources to types What is a type? What is a value?Types are provided on demand Cannot generate all indicator types at once!Representing data source properties as types Physical units, provenance, temporal propertiesAdapting to schema change Type soundness is relative w.r.t. data source changes
  11. 11. Gamma, The ForgottenStandard typing judgmentsGamma on steroids Γ = …, WB.DataContext WB.DataContext = Countries : delay (…) Country listReducing delayed context
  12. 12. Research problemsMapping data sources to types What is a type? What is a value?Types are provided on demand Cannot generate all indicator types at once!Representing data source properties as types Physical units, provenance, temporal propertiesAdapting to schema change Type soundness is relative w.r.t. data source changes
  13. 13. DEMO: XML Type Provider Working with XML data and adapting to schema change
  14. 14. Related WorkCompile-time meta-programming Types generated eagerly, not on demandDependently typed languages Type-level computation in the IO monad??Multi-stage computations Focus on performance vs. data access
  15. 15. For more informationUpcoming technical report Don Syme, et al. Strongly-Typed Language Support for an Information-Rich WorldWorkshop on related topics Data Driven Functional Programming Workshop, Co-located with POPL 2013
  16. 16. SummaryMismatch between data and types Type providers bridge the gap Development-time, compile-time & run-timeInteresting future questions Relative type safety and schema change Capturing meta-data with types
  17. 17. Research problemsMapping data sources to types What is a type? What is a value?Types are provided on demand Cannot generate all indicator types at once!Representing data source properties as types Physical units, provenance, temporal propertiesAdapting to schema change Type soundness is relative w.r.t. data source changes
  18. 18. DEMO: FreeBase Type Provider Working with chemistry data and units of measure
  19. 19. Structure of a Simple Provider[<TypeProvider>]type SampleTypeProvider(config: TypeProviderConfig) = inherit TypeProviderForNamespaces() // Define new type Samples.GeneratedType let thisAssembly = Assembly.GetExecutingAssembly() let providedType = ProvidedTypeDefinition( ... ) do // Add property Hello that just returns a string ProvidedProperty ( "Hello", typeof<string>, IsStatic = true, GetterCode = fun args -> <@@ Runtime.lookup "Hello" @@>) |> providedType.AddMember // Register the type with the compiler this.AddNamespace(namespaceName, [ providedType ])
  20. 20. Compile-Time vs. Run-timeType Provider Runtime API Provider Accesses Data Generates source Uses Accesses Provided codeExecutable
  21. 21. Compile-Time vs. Run-timeType Provider Runtime API Provider Accesses Data Generates source Provided codeExecutable
  22. 22. Queries in F#Can be turned to quotations query { for movie in netflix.Titles do where (movie.Name.Contains(search)) select movie }Extensible query language query { for index in Numbers do reverse takeWhile index > 10 }
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×