Closed JasonKleban closed 8 years ago
@JasonKleban Thanks for the extensive writeup. For now this should really be added to http://fslang.uservoice.com.
My main follow-up question is if you can get the effect you want purely through provided parameters on methods?
can get the effect you want purely through provided parameters on methods?
@dsyme - I don't think so - this example translates parameterized sql into function parameters. To gain type safety for those operations, this information needs to be available at compile-time and be part of the types.
@JasonKleban Thanks - can you add a link to the UV request please?
Can we please track support for TypeProviders providing nested types with static parameters? It seems to me it would be valuable for metaprogramming similar to how static parameterized method support is valuable compared to the language without them. It would allow a fluent-like construction of types and partially make up for the non-variable length static parameters on a single type. Is there a complicated reason that nested parameterized types cannot be supported?
You wrote "Things generally get very nasty when you have a primary set of static parameters on a type" but I'm not sure whether this refers to this support which I'm asking about. I think you're just saying that a statically-parameterized method returning a type dependent on its parameters can get complicated to think about.
An example: Internal DSLs for defining types from other languages can take advantage of the nesting type provision to label different components that aren't clearly delineated in the source language. In this example of a fictitious type provider using this fictitious feature, the
Extend
schema definitions can be split up as shown but could just as well be combined for defining the types in the domain, but theRequireZero
domain invariant specifications which communicate individual domain invariants can need multiple statements and could not clearly be delineated in the source language without comments or manifest files referencing other files or something obnoxious like that.The current alternative is
type myDomain = Domain<"CREATE TABLE Customers ... CREATE TABLE Charges ...", "SELECT ... -- RESERVED_DELIM SELECT ... INTO @Intermediate; SELECT @Intermediate">
but this is inconvenient, even if the literal script were instead a file with those contents.