⬡-49016 on Nostr: ok so network. this one needs help with language design. how the fuck are nix types ...
ok so network. this one needs help with language design.
how the fuck are nix types supposed to work
like. its reasonably doable for values with something like typed: Int = 5;, but for functions?
one option would be just setting the type separately, like fn_typed: a -> [a, a] = v: [v, v]; but thats kinda clunky; its two places describing one thing and always need to be kept in sync
another option would be inlining them somehow. something like fn_inline_typed = a first: b second -> [a, b]: [first, second], but thats also kinda weird, especially with the return type if that cannot be inferred
or just something a bit more traditional like (first: a): (second: b) -> [a, b]: [first, second], but that sucks with the double use of the colon and parens, or just straight up rust with (first: a, second: b) -> [a, b]: [first, second]
also maybe an = for function bodies, as in a first, b second -> [a,b] = [first, second], a bit like in kotlin
like, in a lot of cases the types for functions can be inferred (and yes, function type inference already works in its language, don't ask how) but there should be nice syntax in case that doesnt work
how the fuck are nix types supposed to work
like. its reasonably doable for values with something like typed: Int = 5;, but for functions?
one option would be just setting the type separately, like fn_typed: a -> [a, a] = v: [v, v]; but thats kinda clunky; its two places describing one thing and always need to be kept in sync
another option would be inlining them somehow. something like fn_inline_typed = a first: b second -> [a, b]: [first, second], but thats also kinda weird, especially with the return type if that cannot be inferred
or just something a bit more traditional like (first: a): (second: b) -> [a, b]: [first, second], but that sucks with the double use of the colon and parens, or just straight up rust with (first: a, second: b) -> [a, b]: [first, second]
also maybe an = for function bodies, as in a first, b second -> [a,b] = [first, second], a bit like in kotlin
like, in a lot of cases the types for functions can be inferred (and yes, function type inference already works in its language, don't ask how) but there should be nice syntax in case that doesnt work