Haskell “collections” language design

前端 未结 5 1857
耶瑟儿~
耶瑟儿~ 2021-02-07 03:21

Why is the Haskell implementation so focused on linked lists?

For example, I know Data.Sequence is more efficient with most of the list operations (except for the

5条回答
  •  囚心锁ツ
    2021-02-07 03:37

    I am pretty sure this won't be an answer to your question, but still.

    I wish Haskell had more liberal function names(mixfix!) a la Agda. Then, the syntax for list constructors (:,[]) wouldn't have been magic; allowing us to at least hide the list type and use the same tokens for our own types.

    The amount of code change while migrating between list and custom sequence types would be minimal then.

    About map, you are a bit luckier. You can always hide map, and set it equal to fmap yourself.

    import Prelude hiding(map)
    
    map :: (Functor f) => (a -> b) -> f a -> f b
    map = fmap
    

    Prelude is great, but it isn't the best part of Haskell.

提交回复
热议问题