Functional programmers need to take a look at Zig
pure-systems.org
Functional programmers need to take a look at Zig
1–10 of 163 posts
Re: Functional programmers need to take a look at Zig
#2It'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
Re: Functional programmers need to take a look at Zig
#3Re: Functional programmers need to take a look at Zig
#4io is not a monad. theres nothing stopping you from stashing a global io "object" and just passing the global wherever you interface with the stdlib. 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,…
And he does admit you may have to squint, to appreciate the fp capabilities provided by Zig.
Re: Functional programmers need to take a look at Zig
#5> ...
> 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?
Re: Functional programmers need to take a look at Zig
#6Why write:
EqPoint.eql(a, c)
When you can write:
Point.eql(a, c)
Re: Functional programmers need to take a look at Zig
#7 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 | NothingRe: Functional programmers need to take a look at Zig
#8> Noise is anything that must be written for the program to function that is not relevant to the domain. > ... > 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?
Re: Functional programmers need to take a look at Zig
#9Do you really prefer this: 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