Live data from Hacker News

Super Mario Derivations

fzakaria.com

21–22 of 22 posts

Re: Super Mario Derivations

#21
Why are people so enamored with lazy languages? There's an obvious and easy way to build lazy evaluations in any imperative language: return a data structure with a .run() method instead of the result.

It's the basic principle behind the ML libs for instance, none of which are made in a lazy language since it buys you nothing but really adds complexity (you can no longer do the trivial reasoning "if I ask for A B C, then A happens, then B, then C", the order is never guaranteed and these are the errors you constantly make in languages like haskell and prolog, or at least that goes for me).

This also means you can no longer explicitly optimize. And if compilers were infinitely more intelligent than me that would be fine ... but of course when it matters I can beat every compiler I've ever seen.

Re: Super Mario Derivations

#22

Im confused whats the point of this ?

It's a nice example how one can generate infinite outputs and avoid the problems that normally come with combinatoric explosions from offering too many options. Say you have a program that can use Gtk or Qt, but also supports MP3, Ogg and other formats, all optional, you'll end up with:

foo-gtk, foo-qt, foo-qt-mp3-ogg, foo-qt-ogg, foo-gtk-mp3, ...

That quickly gets out of hand, but you don't have much other choice here, since flakes don't provide a way for the user to say "enableOgg = true", flake outputs are reproducible and thus don't have options.

With this approach you can leave it to the user and they can pick an output like:

foo.withGtk.withOgg.withMp3

The flake generates that output on the fly, it's still reproducible, and works the same way as an option, but it's actually an output, not an input. Since everything is lazy, that output is only created when the user requests it.

PS: `.override` is the other way to do it, but that doesn't work well together with `nix profile`.

Post reply on HN