[Haskell-beginners] Fwd: Functional Dependencies

Brent Yorgey byorgey at seas.upenn.edu
Sat Dec 11 16:18:33 CET 2010


On Fri, Dec 10, 2010 at 11:22:08PM -0800, dan portin wrote:
> Hi,
> 
> *unflt* was a poor choice of name. *flt2*, which flattens a datatype
> containing a flattenable datatype, would have been a better name.
> 
> >
> > If I was making a flatten class, I wouldn't want Monad as a constraint
> > on the result container. Monad doesn't really say anything about
> > "containers" - there are some containers that are Monads, but there
> > are monads that aren't containers and there are containers that aren't
> > monads.
> >
> 
> You're right. My initial class was
> 
> class Monoid m => t -> m where
>    flt :: t -> m
> 
> instance (Tree a) [a] where flt = fltTree
> instance (Maybe a) [a] where flt = maybeToList

It sounds a lot like you want the "Foldable" class from Data.Foldable.
Is that what you are looking for?  If not, can you explain the
particular way in which Foldable does not meet your needs?

-Brent



More information about the Beginners mailing list