Data.* collections maintenance

Bulat Ziganshin bulatz at HotPOP.com
Thu Nov 10 04:53:27 EST 2005


Hello Yitzchak,

Thursday, November 10, 2005, 11:59:49 AM, you wrote:

YG> How about a Strict and Strict Updatable version for
YG> each collection type?

btw, strict and non-strict version of the same routines can be
generated with help of classes:

data Tree a = Tree (Tree a) a (Tree a) | Empty
data StrictTree a = StrictTree !(StrictTree a) !a !(StrictTree a) | StrictEmpty

class Trees t a where
  left, right, isEmpty....

instance Trees Tree where
  left (Tree l e r) = l
  ...

instance Trees StrictTree where
  left (StrictTree l e r) = l
  ...

and all other operations can be implemented in terms of left/right/...

-- 
Best regards,
 Bulat                            mailto:bulatz at HotPOP.com





More information about the Libraries mailing list