logoalt Hacker News

Contracts in Nix

80 pointsby todsacerdotiyesterday at 8:15 AM16 commentsview on HN

Comments

bjackmantoday at 8:31 AM

I was a bit skeptical at first coz my experience so far has been that Nix's weak typing quite rarely causes me problems.

(Likely because NixOS options tend to be how I communicate between pieces of code, and those have a good enough type system).

But actually I think, as something that you just use occasionally like in your JSON example, this could be really cool. I wouldn't wanna use it as "gradual typing" in the sense of aiming to gradually type a whole body of code I think I would be more interested in "selective typing".

Just occasionally when you get that itch of "ugh this will fail really ungracefully if the inputs are bad" then you just apply this where it's needed.

OneDeuxTriSeiGotoday at 11:21 AM

Is this related to the Contracts RFC[1] and associated implementation[2] or is it its own freestanding work unrelated to upstream efforts?

1. https://github.com/NixOS/rfcs/pull/189

2. https://github.com/NixOS/nixpkgs/pull/485453

sermahtoday at 8:12 AM

Fun obscene fact! This site’s domain is sraka.xyz. In russian “sraka” is transliterated as “срака” which literally means ass.

show 1 reply
koiueotoday at 6:18 AM

Looks amazing!

Some time ago I wanted to write a Nix configuration dsl for an application I use. My effort halted due to lack of type checking, and implementing one felt like too much effort which would never pay back.

I'll give a try.

lmmtoday at 5:17 AM

Meh. Runtime assertions are a poor substitute for a type system, even if you give them a type-system-like syntax.

show 2 replies
bojotoday at 4:56 AM

Sorry to be that guy. I love nix, I want to read more about how people use nix.

The font presented under NixOS + Firefox is near unreadable on this website.

show 3 replies
boycothntoday at 6:05 AM

[flagged]