[Haskell-cafe] Extending the idea of a general Num to other types?

Chaddaï Fouché chaddai.fouche at gmail.com
Sun Sep 2 05:23:36 EDT 2007


2007/9/2, Peter Verswyvelen <bf3 at telenet.be>:
> Can the same be done on other builtin constructs? For example, if I have
> [a], can this list be lifted to other types? I guess not, because no
> type class exists for the list type?
>

You can indeed already do that, except it won't be a single instance
since list have a bucketful of interesting properties. A good starting
is looking at what list is an instance of and trying to identify the
set of instance which interest us in this case, Foldable and Functor
are probably a good start, embodying most of the interesting way to
access a data structure as a list (head and tail don't really make
sense for most of the alternatives, except other "sequence" library
which currently provide this functionality in an ad-hoc way, see
Sequence and ByteString for example of that).
An alternative is Traversable.

-- 
Jedaï


More information about the Haskell-Cafe mailing list