On Sat, Sep 27, 2008 at 12:23 PM, Andrew Coppin <[EMAIL PROTECTED]> wrote: > > Can anybody actually demonstrate concretely how FDs and/or ATs would solve > this problem? (I.e., enable you to write a class that any container can be a > member of, despite constraints on the element types.) >
Sure! Using type-families: > class Container c where > type Elem c > insert :: Elem c -> c -> c > instance Container [a] where > type Elem [a] = a > insert = (:) > instance Container ByteString where > type Elem ByteString = Word8 > insert = BS.cons > instance Ord a => Container (Set a) where > type Elem (Set a) = a > insert = Set.insert In GHCi: > :t insert insert :: forall c. (Container c) => Elem c -> c -> c Now the hard part is coming up with a proper API and class hierarchy. -Antoine _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe