Skip to content

Instantly share code, notes, and snippets.

@brodyberg
Created May 6, 2015 19:12
Show Gist options
  • Save brodyberg/f865d19616a9df93358b to your computer and use it in GitHub Desktop.
Save brodyberg/f865d19616a9df93358b to your computer and use it in GitHub Desktop.
Getting AST for F# Type-Provider action
#I @"..\packages\FSharp.Data.2.2.0\lib\net40"
#r @"..\packages\FSharp.Data.2.2.0\lib\net40\FSharp.Data.dll"
open FSharp.Data
type Stocks = CsvProvider<"msft.csv">
let stockData = Stocks.Load("msft.csv")
// Show AST of Rows getter
<@ stockData.Rows @>.Raw
// Normal usage of Rows
stockData.Rows
|> Seq.iter (fun row -> printfn "Date: %A Open: %A" row.Date row.Open)
// Iterate through Rows again, but this time show the AST provided
// that gets the strongly-typed tuple value for the 'Low' column
stockData.Rows
|> Seq.iter (fun row -> printfn "%A" <@ row.Low @>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment