In Haskell, why isn't there a TypeClass for things that can act like lists?

后端 未结 6 964
刺人心
刺人心 2020-12-04 17:59

I\'m reading Learn You a Haskell and I\'m wondering why so many things are acting like a list, and nothing in the Prelude is using the native facility of type classes to set

6条回答
  •  醉话见心
    2020-12-04 18:20

    that offers the : function to unify Data.ByteString, Data.List, Data.ByteString.Lazy, etc?

    There have been attempts to come up with a good a) sequence interface, and b) containers interface, however, unifying data types of different kinds, with different type constraints, has generally made the results non-standard enough that it is hard to imagine putting them in the base library. Similarly for arrays, though the Vector package now has a fairly general interface (based on associated data types).

    There are a couple of projects to unify these various semi-related data types with a single interface, so I'm hopeful we'll see a result soon. Similarly for container types. The result won't be trivial though.

提交回复
热议问题