> ...
> What facilities does the language provide me to create correct-by-construction systems and how easily can I program the type-system.
Isn't programming the type-system orthogonal to the program's domain in the same way that manual memory management is?
Why write:
EqPoint.eql(a, c)
When you can write:
Point.eql(a, c)
fn Maybe(comptime T: type) type {
return union(enum) {
value: T,
nothing,
const Self = @This();
pub fn just(the_val: T) Self { return .{ .value = the_val }; }
pub fn nothing() Self { return .nothing; }
}
}
Over this? data Maybe a = Just a | Nothing var value: ?T = null;
Write: value = 10;
Read: if (value) |x| x+=1I haven't heard anyone writing code in Elixir complain about performance issues.
dnautics•40m ago
It's dependency injection. and yes, you can model dependecies like a monad but most people, even in less pure fp langs, don't.
i don't really say this to just be a pedant, but if you're an fp enjoyer, you will be disappointed if you get the picture that zig is fp-like, outside of a few squint-and-it-looks-like things
tux1968•27m ago
And he does admit you may have to squint, to appreciate the fp capabilities provided by Zig.