Posted by cosmic_quanta 9 hours ago
If I'm on NixOS, should I be installing via ghcup, stack, or nix?
I recall wanting to use Haskell packages that were only available in Nix, but nobody had bothered to make just a normal package.
That of course hurts market share.
It's pretty easy to override things in Nixpkgs though, whether at the system level, or for one application, or just a particular dependency deep in the tree of one script.
Nixpkgs has a bunch of powerful functions to make this easier, e.g. callCabal2nix, makePackageSet, etc.
https://nixos.org/manual/nixpkgs/stable/#haskell-overriding-...
https://github.com/NixOS/nixpkgs/blob/master/pkgs/developmen...
OK, so I put this into Gemini: "show me a non-trivial haskell function and type signature with at least five distinct arguments"
And I get:
---
processRecord :: (a -> b) -> Maybe c -> [d] -> (e -> Bool) -> (b, c, [d], e) -> Either String (b, c, [d], e)
processRecord transform mVal items pred (bVal, cVal, dList, eVal)
| pred eVal = Right (transform (const bVal undefined) mVal, cVal, dList, eVal) -- simplified example logic
| otherwise = Left "Predicate failed on the fifth argument"
---My brain just crashes after the "::".
For the beginner, there isn't enough syntax on offer to discern who's doing what to whom here.
Is there a "function signatures for dummys" somewhere?
template<typename A, typename B, typename C, typename D, typename E>
std::variant<std::string, std::tuple<B, C, std::vector<D>, E> processRecord(std::function_ref<B(A const&)>, std::optional<C> const&, std::span<D>, std::function_ref<bool(E const&)>, std::tuple<B, C, std::vector<D>, E>);
This familiarity can be gained in frankly a day or two of trying, and afterwards you’ll find it to be clear and information dense. The example doesn’t even involve anything truly mind blowing for a beginner yet, like the Traversable class, the lens/traversal/prism signatures, or polymorphic recursion.If someone told me German was easy to learn, I wouldn’t get an LLM to generate me a complex sentence with two clauses and three adjectives and then be like “sure about that?”
`processRecord :: (a -> b) -> Maybe c -> [d] -> (e -> Bool) -> (b, c, [d], e) -> Either String (b, c, [d], e)`
Says: “ give me: 1) a function of a to b, 2) a ‘c’ wrapped in a Maybe, 3) a list of d’s, 4) a function of e to a Bool, 5) a 4 tuple of a, b, list of d’s, and an e
And I will give you either a String or your original tuple back”
It doesn’t really do anything so there’s not much more to explain
If I ask my grandma what she thinks of the supposedly easy Python syntax, or C-style curly braces, her brain would similarly crash. Unless she read an intro to Python or C first.
In other words, do not confuse "I'm unfamiliar with this because it doesn't resemble what I know" with "hard to understand".
If you throw a beginner at any non-trivial code in any language without teaching them anything about the language, then, yeah, it'll be hard for them to figure it out. That says nothing about the language itself, though. That's pretty obvious to everybody.
> Is there a "function signatures for dummys" somewhere?
Yeah, of course. There's actual beginner material, here's one example:
https://learnyouahaskell.github.io/types-and-typeclasses.htm...
Not hard to find, and not the only introduction to the language that covers this material. I guess you never bothered to look, or even to ask Gemini.
-- Here you go
-- Oh my god, it's non-trivial
though i have thought about it.