Conversation
|
Hmm. I think this change is directionally correct and I appreciate it overall, but I'm like... weak -1 on some of the details. Specifically:
|
|
I think I'd withdraw my objection to snake casing if a clash were a compile error instead of a fallback. Because this is a type we entirely create ourselves, the only way you can trigger that (I think) is to have both FooBar and foo_bar as variants names, and frankly fuck you you're on your own if you do that. |
I think the fact that cargo ships a default lint rule that method names be snake_case implies rust as an ecosystem follows this idiom more strongly than other languages. I don't want users to have to suppress warnings for normal hegel usage.; that'll annoy them.
If a user has chosen to do this, they have good reason to and have already suppressed a builtin cargo lint warning to do so. I want the way in which they're on their own to be "we did the best we could to provide you reasonably-named methods", not "we refused to generate any methods".
Agree the inconsistency is bad. But:
|
|
I am still not wild about the clash case, but I basically think it doesn't matter in practice, and will defer to your judgement. Still lightly -1 on the tuple/named inconsistency but you've thought about it more than I have and I agree there's an annoying tradeoff here and that this isn't obviously the wrong point in tradeoff space, so OK. I think being able to pass |
|
I have strong feelings about the clash case and weak feelings about the tuple case. An additional negative mark against my tuple semantics: you can't easily configure fields where the value of one depends on the other. With the |
Hmmm actually yeah I think that convinces me I want to be able to use the closure method here. I would like to be able to override these generators entirely. I'd be sortof OK with having both if you had strong feelings about wanting the (admittedly more convenient for the common case!) version with direct arguments. |
|
I played with this for a while because I do think the
I would really like the ability to write the following: enum_gen.single_field(gen1)
enum_gen.double_field(gen1, gen2)
enum_gen.double_field(compose!(|tc| { let n = tc.draw(...); (gs::just(n), gs::just(n)) })Of course this is not possible with rust's type system. I also realized the limitation I pointed out above of dependent generation in unnamed tuple variants not being possible is also true for named tuple variants, because you can't write I do feel strongly enough here that I'd at least like to fully explore this design space. Here's a crazy idea: what if we always pass enum_gen.single_field(|tc| { (gen) })
enum_gen.double_field(|tc| { (gen1, gen2) })
enum_gen.named_field(|tc, g| { g.x(gs::just(42)})Yes, I actually think in some sense this might be the only option available to us after applying restrictions from both the rust language and our desired usage forms (setting aside multiple methods). |
Huh? Why not? Doesn't
I don't think we should necessarily set aside multiple methods fwiw. |
I'll just restate the release notes here:
I also cleaned up a bunch of the
enum_gen.rscode in our macro, which was splitting out different code paths for no good reason.Closes #149. See also #148.