[HN Gopher] Types for Tables: A Language Design Benchmark
___________________________________________________________________
Types for Tables: A Language Design Benchmark
Author : matt_d
Score : 52 points
Date : 2021-12-10 13:14 UTC (1 days ago)
(HTM) web link (blog.brownplt.org)
(TXT) w3m dump (blog.brownplt.org)
| chrisaycock wrote:
| I created Empirical specifically to have statically typed
| Dataframes (tables). let trades =
| load("trades.csv") from trades select where symbol ==
| "AAPL" and size > 1000
|
| Empirical uses _type providers_ and automatic _compile-time
| function evaluation_ to sample the CSV file and infer a type
| ahead of time. The above can be run in a REPL or in a stand-alone
| script and the result is statically typed! (There is no
| "gradual" or "optional" types; it is fully static.)
|
| Empirical has generic types, which is a syntactic sugar for
| templates. Here is an example of a five-minute volume-weighted
| average price (VWAP): func wavg(ws, vs) = sum(ws
| * vs) / sum(ws) from trades select vwap = wavg(size,
| price) by symbol, bar(timestamp, 5m)
|
| I created Empirical for time-series analysis (I work in finance)
| and began with the question, "What if q/kdb+ were more like
| Haskell?" The result is very different from either language, but
| I wanted to make table actions feel dynamic even though they are
| fully static.
|
| To run a script that takes a command-line argument for the
| location of the CSV file, just supply the type ahead of time
| since there isn't a compile-time path to the file.
| data Trade: symbol: String, timestamp: Timestamp,
| price: Float64, size: Int64 end let
| trades = csv_load{Trade}(argv[1])
|
| Feel free to try it out.
|
| https://www.empirical-soft.com
| gavinray wrote:
| This is pretty interesting.
|
| Are you familiar with the "Morel" dialect of SML?
|
| It's written by Julian Hyde, who has authored several RDBMS and
| is the lead maintainer of the Apache Calcite relational algebra
| framework. Your tool reminds me a bit of the work in Morel,
| where LINQ-like operators have been integrated into the core of
| the language:
|
| https://github.com/julianhyde/morel
| sbr464 wrote:
| (unrelated design notes)
|
| Columns with numerical data should be right-aligned. Column
| header alignment should match the data.
|
| https://alistapart.com/article/web-typography-tables/
| acbart wrote:
| I am so excited about this work! I think it's a wonderful big
| step in this area. However, I am still a little weirded out by
| the term "sort" being used to describe the type of a cell. Their
| goal is to avoid preconceptions about the use of the word, but...
| there's already a lot of baggage around that word "sort"!
| garmaine wrote:
| Uh... isn't this exactly what the (typed) relational model is?
| johnmyleswhite wrote:
| The relational model's type system is contained inside of this
| work as the schema component.
| [deleted]
___________________________________________________________________
(page generated 2021-12-11 23:01 UTC)