0

I recently asked a question which I believe covers all the suggestions on How do I ask to ask:

Write a title that summarizes the specific problem

The question's title includes all the information required to answer the question.

Introduce the problem before you post any code

Yes, I explain the problem and then introduce an example.

Help others reproduce the problem

The code presented is enough to reproduce the problem as it doesn't derive a parser.

Include all relevant tags

This is a question about automatically generating a parser for an arbitrary datatype in Rust. I've included the tags: parsing, generics, rust, algebraic-data-types.

Proof-read before posting!

I did. The question looks brief and understandable.

Look for help asking for help

I spent the previous 10 minutes googling for a solution and found none.


Moreover, the question is objective and has a clear, short, well-defined answer (either the answer is "yes, by doing X" or "no, that's not possible"). It was put on hold for being too broad, which, to me, do not make any sense in this context. What is the reasoning behind that decision?

20
  • 1
    According to the comments, it is hard for to them to define what would "identify as an adequate answer"
    – user9420984
    Nov 27, 2018 at 13:20
  • 1
    I think you've figured it out with your latest edit. People probably thought you were asking for code to do that, they didn't understand you were asking for an existing language feature.
    – user247702
    Nov 27, 2018 at 13:21
  • 9
    Quick aside: "10 minutes" isn't a lot of research (the expectation is to do a crazy amount of research before posting). Now onto your question: In general (and I don't know the domain, so bear with me there), it seems like the question is "I want to do this. What do I do?" which is very broad. There may be subtleties (like Stijn pointed out) that makes this point moot. But at a glance, it definitely looks like that
    – Patrice
    Nov 27, 2018 at 13:22
  • @Patrice (and Codeer): The requirements look well-specified to me, but that is because I am familiar with what Read in Haskell does. (MaiaVictor: Perhaps it would be worth it to explain that a little further in the question.)
    – duplode
    Nov 27, 2018 at 13:24
  • @duplode yeah, there was a very good likelihood that my lack of Haskell knowledge there was leading me astray.
    – Patrice
    Nov 27, 2018 at 13:25
  • How is "a crazy amount of research" defined? Obviously we don't expect people to spend weeks researching such a small problem before asking it, or do we? In that case 10 minutes were enough to exhaust the list of meaningful results on my search.
    – MaiaVictor
    Nov 27, 2018 at 13:33
  • 2
    Note: in the future, if you have issues with a rust question, try hoping on the Rust chatroom. It's easier to go "back-and-forth" in chat format than using the comments, as well as get feedback on how to formulate stuff, etc... Nov 27, 2018 at 13:34
  • 2
    @Patrice To be fair, I wouldn't really describe this as going "astray", given that we are talking about a Haskell feature in a question not tagged [haskell].
    – duplode
    Nov 27, 2018 at 13:35
  • 4
    "How is "a crazy amount of research" defined? " Right here. Never underestimate the amount of effort required to ask a question.
    – E_net4
    Nov 27, 2018 at 13:37
  • 2
    @MaiaVictior I personally don't post my questions until 7 days of me keeping them as a draft. Notice how I only ever asked one question, that was literally a change in the system I had no way to know about? Usually I spend these 7 days searching, adding my research to my question, change my question, research some more. Make some progress, try it out, find other issues, research some more. By the end of the 7 days, I very rarely have a question left to ask, since I found my answer myself. I may be on the other extreme, but "10 minutes" isn't really what we're expecting :/
    – Patrice
    Nov 27, 2018 at 13:40
  • @Patrice oh, that's definitely not how I saw it so far. My understanding was more like: if the time I take to research a question is X times higher than the time it takes for someone else to answer it, then it is reasonable to ask, under a "this is productive for the open-source community" sense. The answer you linked makes sense in a more individualistic view, i.e., if you believe that "answering a question produces value to the one asking, and produces costs to the one answering, who will not get anything in return". I realize now the second view is the most widespread.
    – MaiaVictor
    Nov 27, 2018 at 14:07
  • 1
    Hmya, it isn't always obvious to chat room visitors that don't know anything about the tag subject that "is it possible" was intended to mean "how do I". At which point you'd expect an expert to give you the best solution, regardless of the number of ways to do it. The normal way we used to handle Q+A, it isn't very normal anymore. Nov 27, 2018 at 14:46
  • 4
    There is no problem. Only a time line of the event. Improving your question is a good thing. Edit on your closed post put it in the re-open queue. It's ok to try improve the queuing time by making a meta post. Reading this meta question I had the impression that your question was following the guide line you advocated when it was closed. The time line show that those edit just before meta question look like a 'I've edited now reopen it.'. In fact your meta question reads as "Unfair closure" more that "Help me improve". But thats just my opinions. Nov 27, 2018 at 16:00
  • 4
    Between your 1rst edit and this meta post there is 10 minutes. Between the 2nd one and this meta post there is 4 minutes. I don't think this was a reasonable time frame. Nov 27, 2018 at 16:03
  • 2
    @Patrice I think DragAndDrop's point is that the OP made this meta post much too soon after editing their post for the first time after closure. The amount of time that they allowed for the normal reopen process to occur prior to posting on meta was dramatically less than any reasonable estimate of how long it would take for the question to be reopened through the normal process. A naive estimate would be to expect at least as much time between the first time the question was in good shape (after later edits) and being reopened as there was between first posting the question and being closed.
    – Makyen Mod
    Nov 28, 2018 at 3:45

1 Answer 1

13

Well, the first version of your question was:

Is it possible to derive a parser for an arbitrary enum?

In Haskell, it is possible to derive a parser from an arbitrary datatype to a string: that's called the Read class. Is it possible to do so in Rust? That is, given an arbitrary enum such as:

enum Foo {
    A { x : u32, s : String },
    B { v : Vec<u8> }
}

Can I automatically generate a function parse : &[str] -> Foo?

And as identified in the comments:

Define possible. Yes, it's possible to write code that will write the relevant code; is that what you are asking?

There are multiple ways in Rust to do so:

  • you could use a macro to declare the enum and automatically declare a bunch of related function at the same time.
  • you could code your own version of a derive macro (like serde does), to slap on existing enums and do so.
  • you could expect a library to provide such a functionality.
  • you could expect the standard library to provide a reverse of derive(Debug).

It was not clear whether your question was:

  • can I write code to do so (macro or derive)?
  • is there a library to do so?
  • is there a standard feature to do so?
  • is there a language feature to do so?

Only in edit 5, after asking this question, did you finally clarify that you were asking about pre-existing code (and not how to write such code).

Now, being clear, your question is on the way to being re-opened.

The process works :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .