[Haskell-cafe] Dynamic choice of "reverse" implementation

Ross Paterson ross at soi.city.ac.uk
Fri Sep 28 13:59:36 EDT 2007

On Fri, Sep 28, 2007 at 05:54:23PM +0100, Brian Hulley wrote:
> Yes this type should be fine. To implement reversor though you'd still need 
> to first convert from the concrete list to whatever foldable you're using, 
> before reversing the foldable, or implement something more general eg:
>     reversor :: (Foldable f, Foldable g) :: f a -> g a

One cannot define such a function, as Foldable provides no way to build
things.  However one can define

	reversor :: Traversable f => f a -> f a

which returns something of the same shape, but with the contents reversed.

More information about the Haskell-Cafe mailing list