3 ms·
What cruft?
by kreetx 2y ago
What cruft?
- tasuki 2y agoThe standard library is atrocious, mainly I believe for historical reasons: - map only works on Lists (one needs fmap for functors) - head throwing exceptions instead of returning Maybe - dependent types bolted on later: they're much nicer in Idris
- kreetx 2y ago- map is easier on newcomers. Once you you understand functor, you'll remember to use fmap anyway. Also, I still use map for lists after 10+ years. - I don't fully understand this, but do you mean that every `IO a` function would be better off being `IO (Maybe a)`? - AFAIK, there are no dependent types in Haskell yet, but say that the type level programming you can do today is what you mean then you are already in quite advanced territory. Yeah, I guess it could be more polished.
- tasuki 2y agoI mean that `head` should be `List a -> Maybe a` rather than `List a -> a`. If you really really want an `a`, you should provide `NonEmptyList a` or something.
- tromp 2y agoHaskell provides https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-List-NonEmpty.html https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-...
- kreetx 2y agoI agree! The current `head` should be renamed `unsafeHead` (or something), and the new `head` should have the type you wrote.
- tome 2y ago> head throwing exceptions instead of returning Maybe The choice is keep it is it is, or change it. Changing it would break vast amounts of existing code. Which option do you prefer?
- kqr 2y agoI think this was given as an example of necessary-but-annoying cruft, not as a suggestion for change.
- simonmic 2y ago“atrocious” ? I don’t think that’s any Haskeller’s experience. We can point to a few things we’d like to be different for modern Haskell dev, which are slow to improve because of legacy etc, and a certain fragmentation across different packages, but relatively speaking, base and other core libs provide a wealth of high quality, well documented, principled utilities.
- EE84M3i 2y agoExceptions n+k patterns Lazy IO