Github repo: https://github.com/philnguyen/json-type-provider

I read this PLDI 2016 paper 
<https://dl.acm.org/citation.cfm?id=2908080.2908115> about Type Provider 
for F# and attempted to implement it as a Racket macro. Then I realized it 
worked great in F# mostly because of dot notation and IDE auto-completion. 
I ended up implementing something more manual and primitive, but hopefully 
is still useful.

Background: Type Provider statically generates types that describe data 
from external sources (e.g. JSON, XML, CSV, etc.) and parsers that produce 
values of those types, eliminating error-handling boilerplate when parsing 
and coercing the raw inputs. In F#, programmers can provide example inputs 
(such as paths to local files or external links), and the compiler infers 
the shape of the data for them. Thanks to OOP's dot notation and IDE 
auto-completion, programmers can explore the data's shape interactively as 
they program.

Unfortunately, auto-completion doesn't work so well in Racket, so the 
result of example-based type+parser generation will likely be unpredictable 
to humans merely seeing links in the source code.

As a compromise (and maybe a building block for future work), I made a 
library that generates JSON parsers from high-level Typed Racket 
declaration. It's manual, but there are still a few nice things:
* The available types and properties are obvious from the source code
* It eliminates error-handling boilerplate
* By default, it stores JSON objects compactly as structs, only holding the 
fields the programmer cares about
* It allows converting JSON objects to arbitrary types on the fly in 1 pass.
* If it turns out there's a way to make example-based code generation and 
auto-completion work well in Racket's context, hopefully it'll just be 
another step on top of this library, where the macro is generated from 
examples.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/aa01bf12-8a56-4ccd-a988-3b0fd800cce9%40googlegroups.com.

Reply via email to