3 ms·
> Rust pulls some really nice trick, but cannot match Haskell. I'm not convinced that's true. Rust is even stricter than Haskell in many respects (first exampl
by fjh 11y ago
> Rust pulls some really nice trick, but cannot match Haskell.
I'm not convinced that's true. Rust is even stricter than Haskell in many respects (first example that comes to mind is incomplete pattern matches, which is a compiler error in rust) and strictness also avoids some run-time errors. I've managed to produce infinite loops in Haskell by accidentally defining recursive values more than once.
- sksk 11y agoWhile I agree with you about pattern matches in Haskell but for completeness sake there is a ghc flag -W for it. If you compile this code with that flag, you will see the result below: --hello.hs f mx = case mx of Just x -> x --Nothing -> "NA" main = do let v = Just "5" putStrLn $ f v ghc -W hello.hs [1 of 1] Compiling Main ( hello.hs, hello.o ) hello.hs:1:8: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: Nothing
- tome 11y agoIn my opinion, incomplete pattern matches should be an error not a warning, but it seems strange to choose a different language based on that issue.