dingo: A meta-language for Go

68 points by telemachus


gasche

I looked at the pattern-matching code (because I know about this stuff). I find the code weird (pattern_match.go, exhaustiveness.go).

  1. I would expect that patterns form a tree, for example Ok(x, Some(y)). The representation of match expressions is designed as if a pattern was either a Result, or an Option, or a Tuple, it does not seem to support nesting them.

  2. There is no abstract syntax tree to represent patterns, match expressions, etc. For example constructor names are strings. In general datatypes are weird, they use poor types that are not informative. For example, the function that checks looks for counter-examples to exhaustiveness (patterns that are not covered) returns a list of strings (that is, a list of already-formatted counter-examples), whereas I would naively expect a list of patterns.

    I would have naively expected a standard compiler that parses an extension of the Go syntax into an abstract representation, then transforms it into Go code. But the datatypes and API design are a bit strange, in-between "low-tech hack" and "proper compiler". I don't know if this is idiomatic Go style, or a design choice (made by a human or by a machine) that would deserve an explanation and may be questionable.

  3. I have the impression that there is something wrong in the findMissingPatterns function, when it checks hasWildcardAtPosition. For example if I use the tuple patterns

    (Ok(x), Error(y)) -> ...
    (_,        Ok(y)) -> ...
    

    At position 0, one of the clauses has a wildcard, but continuing looking for counter-examples of the form (Ok, _) is not quite correct -- there are no counter-examples of this form, but (Error, Error) is not covered.

j3s

interesting project -- though the readme reeks of AI.

note to people writing projects: using LLMs to generate rote, boring crap is fine, but the description of your project should be hand-written if you want it to resonate. you're telling a story, and humans are great storytellers.