3 ms·
- 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 f
by 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.