Hi, the Prelude docs found via http://haskell.org/hoogle/hoodoc.cgi?module=Prelude&name=Functor&mode=class claim that there is an instance Functor ((,) a) And yet, I get (in GHC, but similarly in Hugs): Prelude> fmap (+1) (undefined,2) <interactive>:1:0: No instance for (Functor ((,) a)) arising from use of `fmap' at <interactive>:1:0-22 Possible fix: add an instance declaration for (Functor ((,) a)) In the expression: fmap ((+ 1)) (undefined, 2) In the definition of `it': it = fmap ((+ 1)) (undefined, 2) What do I have to import to get the Functor ((,) a) instance? (Of course, I can define it myself, but this is not the point.) Thanks, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de
On Wednesday 19 September 2007, Janis Voigtlaender wrote:
Hi,
the Prelude docs found via
http://haskell.org/hoogle/hoodoc.cgi?module=Prelude&name=Functor&mode=class
claim that there is an instance
Functor ((,) a)
And yet, I get (in GHC, but similarly in Hugs):
Prelude> fmap (+1) (undefined,2)
<interactive>:1:0: No instance for (Functor ((,) a)) arising from use of `fmap' at <interactive>:1:0-22 Possible fix: add an instance declaration for (Functor ((,) a)) In the expression: fmap ((+ 1)) (undefined, 2) In the definition of `it': it = fmap ((+ 1)) (undefined, 2)
What do I have to import to get the Functor ((,) a) instance?
(Of course, I can define it myself, but this is not the point.)
In GHC 6.6 and above, you'll need to import Control.Monad.Instances (a bit of a weird place to put it, but I guess there's no Control.Functor and such). If you have an earlier version than that, I'd say import Control.Monad.Writer at a guess. -- Dan
Dan Doel wrote:
What do I have to import to get the Functor ((,) a) instance?
(Of course, I can define it myself, but this is not the point.)
In GHC 6.6 and above, you'll need to import Control.Monad.Instances (a bit of a weird place to put it, but I guess there's no Control.Functor and such).
If you have an earlier version than that, I'd say import Control.Monad.Writer at a guess.
Thanks a lot. Works! BTW, what would have been the easiest way for me to find this out on my own? Somehow, I would have hoped to be able to navigate to the appropriate point from the mentioned place in the online docs, where it is stated that the instance in question exists. Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de
participants (2)
-
Dan Doel -
Janis Voigtlaender