Recent submissions

Comment · 2 years ago
I'd like to believe this too, but given that medieval peasants and antique slaves worked more or less the same hours as we do I'm quite pessimistic. Whenever we automate something they just come up with a new bullshit job that adds nothing to the standards of living, instead of reducing the workload for everyone.
Comment · 2 years ago
> And defining a function that will only accept particular variant is nice

This is possible to achieve (or hack your way through, if you will) by parameterizing the type and using a nullary type (a type which is impossible to have) to exclude specific cases of a sum type. In Haskell this would look like this:

    data Weather a b c = Sunny a | Rainy b | Snowy c

    -- can't snow in the summer!
    onlySummerWeather :: forall a b. Weather a b Void -> String
    onlySummerWeather weather = case weather of
      Sunny _ -> "Got sunny weather"
      Rainy _ -> "Got rainy weather"
      Snowy v -> absurd v
where `absurd :: forall a. Void -> a` "if you give me something you can't ever have, I will give you anything in return".
Comment · 2 years ago
It is well known that Binance, among many other crimes, runs many internal trading desks which trade against Binance's own customers.
Comment · 2 years ago
> so I eventually gave up and just made fish itself my nushell's completion engine

That's an interesting idea. Do you have a link to show how you did this?

Comment · 2 years ago
> BTW I believe `-C` will disable some cache checking, caching is enabled by default

You're right, my memory has let me down.

> Do you have any pointers for the "load on tab" idea? I didn't turn up any good results in DDG and LLMs were just hallucinating.

The simplest implementation would be something like

    bindkey ^I init_completions

    init_completions () {
      # ... init logic here ...

      # rebind tab to complete
      bindkey ^I complete-word
      # actually do complete the initial request
      zle complete-word
    }
Edit: I see now you already figured it out, yeah that's exactly what I meant
Comment · 2 years ago
> much faster than zsh script completions

I'm curious where did you get that from.

Edit: I read the note in your dotfiles repo. Yes calling `compinit` on each shell invocation is going to be really slow. That's not how you're supposed to do it, you could at least add the `-C` flag to cache the completions. Ideally you'd also use `zcompile` to compile the cache to ZSH word code. This puts my completions initializing time at ~20ms on a lower/mid-end laptop. Additionally you can do the trick `fish` does and defer the initialization of completions until the first hit of Tab key, so the impact on shell startup time is exactly 0.

Comment · 2 years ago
I'm shifting towards simply "not having" a home directory. Actual data is stored on other partitions, eg `~/git/project1` => `/git/project1`, `~/Pictures/Wallpapers` => `/data/Pictures/Wallpapers`, etc. The shell can be set up to spawn in some custom directory, $CDPATH can be altered for quicker navigation or completions, configurations are managed by Nix so I simply don't have a reason to look at my $HOME that often.

Programs can pollute it all they want, since I don't use it myself I also don't have to care about that.

Comment · 2 years ago
Not fast at all in my experience. Just running (for the first time) what would take seconds with something like `asdf` could take up to half an hour with Nix.
Comment · 2 years ago
Comment · 2 years ago
This function would use an anonymous record:

    splitString :: { pattern :: String, string :: String } -> Array String
    splitString { pattern, string } = ...
This function would use positional arguments:

    splitString :: Pattern -> String -> Array String
    splitString pattern string = ...
Comment · 2 years ago
> Because possibly you return the partial assuming it's a number, and try to use it somewhere else, possibly even in another file.

Sorry, I must've been more explicit instead of implying certain usage patterns. What I meant here is that I have a hard time imagining this happening because I would start working on a function by writing its type signature. Unless my types check out, I won't be able to mark this function as "done" and jump to another part of code. So the situation "you return the partial assuming it's a number" simply can not happen, that's exactly what type checking is for. By the time I use it in another place, it has to already have been type checked.

Comment · 2 years ago
I don't really understand the distinction between "multi-arity" and "unary" functions. In my mental model, all functions are unary, it's just that in "traditional", non-FP languages it's more common to pack arguments into tuples. That is `(a, b, c) => ...` in JS is a unary function which takes a tuple of 3 items. But the thing is, FP has tuples too (and in Haskell, with pretty much the same syntax), it's just that most of the time arguments aren't packed into tuples.

So could you elaborate to me where the distinction lies here and why is there a need to "simulate" things?

Comment · 2 years ago
> What if you forget, not in quotes, to give the second argument?

I will get a type error and it will take me 2-3 seconds to figure out what it is about.

> Why on earth would you want to get a type error in a completely different part of the code because you got a function instead of an integer?

Why would it be in a completely different part of the code? At most it would be 2 lines away, but usually on the same line.

Comment · 2 years ago
Comment · 2 years ago
> After like ten or fifteen hours of trying to understand what currying is, I still have no idea

Maybe you could recall which learning materials you used?

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton