Hacker News new | past | comments | ask | show | jobs | submit | andreypopp's comments login

checkout http://docopt.org then


That seems to be an abandoned project


Yes, according to the archived Rust implmentation[1] which in turn refers you to either clap[2] or structopt[3]. Other implmentations does not mention this but those I looked at had not been touched for years. Either very stable or unmaintained. Unfortunately the latter according to the Rust crate. The dotNet implmentation had a very small version bump in the dependencies but the rest of the project does not seem to have been touched the past 2 years.

[1] https://github.com/docopt/docopt.rs

[2] https://docs.rs/clap/latest/clap/

[3] https://docs.rs/structopt/latest/structopt/


FWIW, there seems to be a less-abandoned fork here: https://github.com/jazzband/docopt-ng

I'm sticking with argparse though


structopt became part of clap proper (as `clap_derive`) when clap v3 was released.


Whoah, that's a neat tool! I definitely need to implement this with my scripts.

Thanks!


It's abandoned, and tbh it's more trouble than it's worth. It's far easier and more reliable to specify the CLI and have it generate the help text than the other way around. All major languages have good CLI parsing libraries (some in the stdlib itself, like Go and Python).


Yeah..... it seems like it would be fragile and require lots of iterating to converge on a help doc that is both "pretty" and correctly parsed by docopt


It's a neat idea (I maintained an unofficial C port for a while); but, terrible in practice.


Would be interesting to know what’s the plan regarding supporting effects in melange. IIRC jsoo (the another OCaml to JS compiler) is doing some whole program analysis to compile to efficient CPS.


Does it (Dart, C#) support exhaustivity checking for such matching over subclasses?


I don't know about C#, but, yes Dart has quite sophisticated exhaustiveness checking over sealed class hiearchies, including hierarchies that are DAGs and not just trees. It also handles record/tuple types and generics, nested arbitrarily deeply. And patterns that call arbitrary getters on objects.

For example, if you have this class hierarchy:

    sealed class A {}
    sealed class B1 implements A {}
    sealed class B2 implements A {}
    class C1 implements B1 {}
    class C2 implements B1, B2 {}
    class C3 implements B2 {}

    //       A
    //      / \
    //    B1   B2
    //   / \  / \
    // C1   C2   C3
Then it understands that this switch statement is exhaustive:

    void test(A a1, A a2) {
      switch ((a1, a2)) {
        case (A(), C1()): print(1);
        case (C2(), C2()): print(2);
        case (C3(), B2()): print(3);
        case (B1(), B2()): print(4);
      }
    }
Because they cover the Cartesian product of all possible combinations of subtypes like:

            a1
                   A
                  / \
                B1   B2
               / \  / \
             C1   C2   C3
    a2     +----+----+----+
         C1|      1       |
      B1<  +----+----+----+
    A<   C2|    |  2 |    |
      B2<  +    +----+ 3  +
         C3| 4       |    |
           +----+----+----+
This can extend to arbitrary dimensions based on how many record fields there are.

Figuring that all out was quite the challenge! The full design is here:

https://github.com/dart-lang/language/blob/main/accepted/3.0...


thanks tons for that amazing comment. Helped me tremendously. Illustrations are incredibly helpful in cases like this.


You're welcome.

The real challenge is that pictures like this only work for simple two-element tuples. Once you have more fields in the tuple, or nested destructuring, the manifold of the value space the patterns have to cover quickly gets into higher dimensions that are basically impossible to visualize.


Yeah but you helped me over the initial hump. Much easier to get to the more involved cases now.


Bravo! This is awesome.


https://dart.dev/language/class-modifiers-for-apis#the-seale...

that first paragraph, i believe, addresses your question, with excellent example from munificent in sibling comment.


Not sure about Dart, but for C# I don't think it can (due to classes being open by default).

If anyone is interested in a deeper dive on C# and adding Discriminated Unions, this interview by Nick Chapsas with Mads Torgersen is a great discussion: https://youtu.be/Nuw3afaXLUc?t=3939 (note, I'm pretty sure this time stamp is the right part, but the discussion might start before this. I'm at work and can't listen too closely to the video atm).


After re-watching, exhaustiveness is not a feature yet. If you look above to munificent's comment, you'll see that Dart has it! very cool!


yes, you declare your class 'sealed' (introduced in Dart 3.0)


Agreed here, it's impressive how easy it is to use and how performant it is.

Would be nice to add a seamless ability to call executable UDFs from clickhouse-local, last time I checked clickhouse-local required executables to be in a special directory (as in proper clickhouse). Instead it'd be nice to be able to reference any executable in an ad-hoc way.


OCaml has a similar thing but purely on syntactic level — http://jobjo.github.io//2019/04/24/ocaml-has-some-new-shiny-...


BQN brings back joy of programming for me — I was using it for Advent Of Code 2021 and it was so much fun.

Also check out BQNPAD[1], the online BQN REPL built with codemirror (syntax highlighting, history).

[1]: https://bqnpad.mechanize.systems


To be honest it seems vim/neovim ticks all those points already.


Yes, however (neo)vim plugin installation still isn't as easy to work with as a one click package / language server install like in VSCode. I thought OniVim would bring that but it seems it is not anymore.


CodeMirror 6 is an awesome piece of software and very flexible — I was even able to build a notebook UI with it — https://bqnpad.mechanize.systems/notebook — this is a notebook (WIP) for BQN[1].

The nice thing is that the whole notebook is a single CodeMirror editor with cells stored as ranges in CodeMirror state. This way intercell actions like selection/copy/paste are possible and still you can control execution per cell.

Shortcuts at https://bqnpad.mechanize.systems/notebook

* Shift+Enter to eval cell

* Cmd-Enter to create new cell

* Cmd-Option-Enter to split cell at cursor

* Cmd-Backspace to join cell with the previous one

[1]: https://mlochbaum.github.io/BQN/index.html


It's very cool to see ngn/k on the HN front page.

After the recent AoC which I've attempted to solve with BQN[1] (another array language) I've got interested in array languages and now exploring K too.

K seems like a nice blend between an array language and a lisp: list is a primary data structure in K, no multidimensional data. K is good at symbolic workloads as well — visit http://nsl.com for some examples.

Also, make sure to check out the C code style ngn/k is written with :-) another K implementation Kona (uses similar C code style) has a wiki page with explanation[2].

[1]: https://mlochbaum.github.io/BQN/index.html [2]: https://github.com/kevinlawler/kona/wiki/Coding-Guidelines


> I've got interested in array languages and now exploring K too.

https://www.arraycast.com/ announced last year (https://news.ycombinator.com/item?id=27209093) may interest a similar audience as this announcement


It's impressive that the entire thing is in pl/pgsql (apart from parsing).

Have you considered any other implementation strategies (C native extension, any other pl/* or maybe running an out of PostgreSQL process which does GraphQL to SQL compilation)?


Yes! We've been exploring https://github.com/tcdi/pgx internally so we'd be able to re-work the hotspots in rust.

We haven't decided to go that route yet but its been incredibly easy to work with & I'm psyched about what options it could open up like:

- Stateless requests (no schema cache)

- Subscriptions (via a background worker)


Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: