1 Mar 2006 01:26
Help with Type Class
Alson Kemp <alson <at> alsonkemp.com>
2006-03-01 00:26:44 GMT
2006-03-01 00:26:44 GMT
Although the discussion about Array refactoring died
down quickly on the Haskell' mailing list, I've been
noodling on refactoring the various Collections in
Haskell. In doing so, I've bumped into a problem with
type classes that I can't resolve. The issue is as
follows:
I'm designing a Collections class heirarchy that is
a blend between that of Java and of Haskell. The
problem is that, whereas in OOP it is easy to do so,
Haskell class mechanism seems to make it difficult to
add *new* member variable to subclasses.
Simple goal: create a top-level Collection with an
*indexed* Array subclass (and various other
subclasses). The problem I'm running into is
Collection has no need of an "index" variable and I
can't seem to figure out how to add an "index" to
Array when subclassing from Collection Mock up:
--
class CollectionClass c e where
-- every Collection supports toList...
toList :: c e -> [e]
class (CollectionClass a e)=> ArrayClass a e where
...
data Array i e = Array i i
(Continue reading)
Couldn't your editor just be a little bit smarter? E.g. count the {-s
RSS Feed