I wanted a Traversable instance for pairing, so I defined one:<br><br>> {-# LANGUAGE TupleSections #-}<br>> {-# OPTIONS_GHC -Wall -fno-warn-orphans #-}<br><br>> import Data.Traversable (Traversable(..))<br>> import Data.Foldable (Foldable(..))<br>
> import Control.Applicative ((<$>))<br><br>> instance Traversable ((,) o) where<br>> sequenceA (o,fa) = (o,) <$> fa<br><br>However, Foldable is a superclass of Traversable, so I get an error message:<br>
<br> Could not deduce (Foldable ((,) o)) from the context ()<br> arising from the superclasses of an instance declaration<br><br>The best I've thought of is the following:<br><br>> instance Foldable ((,) o) where<br>
> fold (_,m) = m<br><br>However, I don't like how it discards information.<br><br>Some questions:<br><br>* Why is Foldable a superclass of Traversable?<br>* Is there a good choice of a Foldable instance of ((,) o)?<br>
* Are there any other problems with the Traversable instance above (besides foldability)?<br><br>- Conal<br>