i was wondering if it's possible to generate a something similar to a simple type provider (Record or Union, with no members, just the matching name with the string name) from a string, at compile time.
mixing this
http://www.readcopyupdate.com/blog/2014/09/18/faking-typeclasses-using-static-type-constraints.html
and this
Create Discriminated Union Case from String
or a similar approach to record types.
what i would like to obtain in, for example (not necessarily with the same approach):
[<Literal>]
let myTypeName = "One"
type SingleStringTypeProvider = ... (here implementation)
type Provided = SingleStringTypeProvider<singleString>
let typeName = typeof<Provided.One>.Name
final result: One is a Type at compile time (and not a method nor a function)
Aucun commentaire:
Enregistrer un commentaire