
Hi, I’m reading Typeclassopdedia and an exercise is "A good exercise is to implement Functor instances for Either e, ((,) e), and ((->) e).” so I have instance Functor ((,) a) where fmap = undefined which gives compiler error Duplicate instance declarations: instance Functor ((,) a) -- Defined at /Users/mike/haskell/FingerTrees/M.hs:65:10 instance Functor ((,) a) -- Defined in ‘GHC.Base’ so I added import GHC.Base hiding ((,)) but I still get the error. Where am I going wrong? Many thanks Mike

Duplicate instance declarations:
it appears that there is (or was?) no way to hide instance definitions: https://mail.haskell.org/pipermail/haskell-cafe/2009-July/063842.html however looking at the exercise: "... implement Functor instances for Either e, ((,) e), and ((->) e).” does this not suggest 1) instance Functor Either e, ((,) e) and 2) instance Functor Either e, ((->) e) ?

... or: 1) instance Functor Either e ((,) e) 2) instance Functor Either e ((->) e) ?

Mmmm I think its functor for each of Either e ((,) e) and ((->) e) ?
On 24 Oct 2015, at 14:16, Imants Cekusins
wrote: ... or:
1) instance Functor Either e ((,) e) 2) instance Functor Either e ((->) e)
? _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

You can try NoImplicitPrelude language extension (this may not work, too)
or use newtype wrappers or normal data types with the same shape.
Dne 24.10.2015 16:05 napsal uživatel "Imants Cekusins"
I think its functor for each of ...
sorry, you are right.
well maybe it is possible with a non-ghc compiler? _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

For the purpose of learning the material, it might be easiest to just write:
class MyFunctor f where
myFmap :: (a -> b) -> f a -> f b
and then create instances of that, instead.
This way, you won't have any conflicts with existing instances.
On Sat, Oct 24, 2015 at 10:16 AM, Petr Vápenka
You can try NoImplicitPrelude language extension (this may not work, too) or use newtype wrappers or normal data types with the same shape. Dne 24.10.2015 16:05 napsal uživatel "Imants Cekusins"
: I think its functor for each of ...
sorry, you are right.
well maybe it is possible with a non-ghc compiler? _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

Yes! It’s obvious once its pointed out. Thanks
On 24 Oct 2015, at 16:25, Ryan Trinkle
wrote: For the purpose of learning the material, it might be easiest to just write:
class MyFunctor f where myFmap :: (a -> b) -> f a -> f b
and then create instances of that, instead.
This way, you won't have any conflicts with existing instances.
On Sat, Oct 24, 2015 at 10:16 AM, Petr Vápenka
mailto:petr.vapenka@gmail.com> wrote: You can try NoImplicitPrelude language extension (this may not work, too) or use newtype wrappers or normal data types with the same shape. Dne 24.10.2015 16:05 napsal uživatel "Imants Cekusins"
mailto:imantc@gmail.com>: I think its functor for each of ...
sorry, you are right.
well maybe it is possible with a non-ghc compiler? _______________________________________________ Beginners mailing list Beginners@haskell.org mailto:Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org mailto:Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (4)
-
Imants Cekusins
-
Mike Houghton
-
Petr Vápenka
-
Ryan Trinkle