In most functional languages, Haskell included, it is simplicity itself to define a linked-list type:
data List a = Nil | Cons a (List a)
However, I couldn't find anywhere in the Haskell tutorials that I have seen that showed how to define your own array type. How does one define an array data type in the way we defined our own list out of nothing?
Note: My question is not about how to use arrays in Haskell; it is merely how to, in theory, define one's own array type, like what was done for List
, without using any sort of library or built-in functionality.