
Hello, When importing Control.Monad.Error, it shows me that (Either e) is an instance of MonadFix, but not an instance of Monad. Isn't there a problem?

On Tuesday 22 February 2011 23:07:05, Yves Parès wrote:
Hello,
When importing Control.Monad.Error, it shows me that (Either e) is an instance of MonadFix, but not an instance of Monad. Isn't there a problem?
Prelude Control.Monad.Error> :i Either data Either a b = Left a | Right b -- Defined in Data.Either instance (Eq a, Eq b) => Eq (Either a b) -- Defined in Data.Either instance Monad (Either e) -- Defined in Control.Monad.Instances instance Functor (Either a) -- Defined in Control.Monad.Instances <snip> instance MonadFix (Either e) -- Defined in Control.Monad.Fix <snip> Works right here. With mtl-1.*, there's an (Error e) restriction on the instances.

I am using mtl-2. Importing Control.Monad.Error doesn't work, I have
to explicitly import Control.Monad.Instances.
2011/2/22 Daniel Fischer
On Tuesday 22 February 2011 23:07:05, Yves Parès wrote:
Hello,
When importing Control.Monad.Error, it shows me that (Either e) is an instance of MonadFix, but not an instance of Monad. Isn't there a problem?
Prelude Control.Monad.Error> :i Either data Either a b = Left a | Right b -- Defined in Data.Either instance (Eq a, Eq b) => Eq (Either a b) -- Defined in Data.Either instance Monad (Either e) -- Defined in Control.Monad.Instances instance Functor (Either a) -- Defined in Control.Monad.Instances <snip> instance MonadFix (Either e) -- Defined in Control.Monad.Fix <snip>
Works right here. With mtl-1.*, there's an (Error e) restriction on the instances.

On Wednesday 23 February 2011 09:58:56, Yves Parès wrote:
I am using mtl-2. Importing Control.Monad.Error doesn't work, I have to explicitly import Control.Monad.Instances.
Weird. Control.Monad.Error imports Control.Monad.Instances (), so it ought to be visible. What exact versions of mtl, base, GHC are you using?
2011/2/22 Daniel Fischer
: On Tuesday 22 February 2011 23:07:05, Yves Parès wrote:
Hello,
When importing Control.Monad.Error, it shows me that (Either e) is an instance of MonadFix, but not an instance of Monad. Isn't there a problem?
Prelude Control.Monad.Error> :i Either data Either a b = Left a | Right b -- Defined in Data.Either instance (Eq a, Eq b) => Eq (Either a b) -- Defined in Data.Either instance Monad (Either e) -- Defined in Control.Monad.Instances instance Functor (Either a) -- Defined in Control.Monad.Instances <snip> instance MonadFix (Either e) -- Defined in Control.Monad.Fix <snip>
Works right here. With mtl-1.*, there's an (Error e) restriction on the instances.

The latest, I think :
GHC 7.0.1,
mtl-2.0.1.0,
base-4.3.0.0
2011/2/23 Daniel Fischer
On Wednesday 23 February 2011 09:58:56, Yves Parès wrote:
I am using mtl-2. Importing Control.Monad.Error doesn't work, I have to explicitly import Control.Monad.Instances.
Weird. Control.Monad.Error imports Control.Monad.Instances (), so it ought to be visible. What exact versions of mtl, base, GHC are you using?
2011/2/22 Daniel Fischer
: On Tuesday 22 February 2011 23:07:05, Yves Parès wrote:
Hello,
When importing Control.Monad.Error, it shows me that (Either e) is an instance of MonadFix, but not an instance of Monad. Isn't there a problem?
Prelude Control.Monad.Error> :i Either data Either a b = Left a | Right b -- Defined in Data.Either instance (Eq a, Eq b) => Eq (Either a b) -- Defined in Data.Either instance Monad (Either e) -- Defined in Control.Monad.Instances instance Functor (Either a) -- Defined in Control.Monad.Instances <snip> instance MonadFix (Either e) -- Defined in Control.Monad.Fix <snip>
Works right here. With mtl-1.*, there's an (Error e) restriction on the instances.

I have the same problem with instances of Functor.
For instance when I import Control.Applicative, to get the instance
"Functor ((->) a)" I also have to import Control.Monad.Instances.
2011/2/23 Daniel Fischer
On Wednesday 23 February 2011 14:14:46, Yves Parès wrote:
The latest, I think : GHC 7.0.1, mtl-2.0.1.0, base-4.3.0.0
Hmm, that's exactly what I have. Weirder and weirder. For the moment, I'm out of ideas.

When I look at the documentation of Control.Monad.Error [1] or
Control.Applicative [2] it is not said that it re-exports
Control.Monad.Instances. So maybe this behaviour is normal...
[1]
http://hackage.haskell.org/packages/archive/mtl/2.0.1.0/doc/html/Control-Mon...
[2]
http://hackage.haskell.org/packages/archive/base/4.3.0.0/doc/html/Control-Ap...
2011/2/24 Yves Parès
I have the same problem with instances of Functor. For instance when I import Control.Applicative, to get the instance "Functor ((->) a)" I also have to import Control.Monad.Instances.
2011/2/23 Daniel Fischer
: On Wednesday 23 February 2011 14:14:46, Yves Parès wrote:
The latest, I think : GHC 7.0.1, mtl-2.0.1.0, base-4.3.0.0
Hmm, that's exactly what I have. Weirder and weirder. For the moment, I'm out of ideas.

On Saturday 26 February 2011 12:54:02, Yves Parès wrote:
When I look at the documentation of Control.Monad.Error [1] or Control.Applicative [2] it is not said that it re-exports Control.Monad.Instances. So maybe this behaviour is normal...
I don't think so. Instances are automatically propagated, they can't be hidden once they're in scope. Functor, Monad, Either and (->) are all available in the Prelude, so unless you have NoImplicitPrelude, the instances ought to be in scope from any transitive dependency. And they are in scope for me when I import Control.Monad.Error or Control.Applicative, so something is amiss if they're not in scope for you.

I tried reinstalling GHC 7.0.1 from scratch, the issue remains...
2011/2/26 Daniel Fischer
On Saturday 26 February 2011 12:54:02, Yves Parès wrote:
When I look at the documentation of Control.Monad.Error [1] or Control.Applicative [2] it is not said that it re-exports Control.Monad.Instances. So maybe this behaviour is normal...
I don't think so. Instances are automatically propagated, they can't be hidden once they're in scope. Functor, Monad, Either and (->) are all available in the Prelude, so unless you have NoImplicitPrelude, the instances ought to be in scope from any transitive dependency. And they are in scope for me when I import Control.Monad.Error or Control.Applicative, so something is amiss if they're not in scope for you.
participants (2)
-
Daniel Fischer
-
Yves Parès