Re: [Haskell-cafe] another instance of MonadError

You can't do that; sorry. You can always turn a string into an IOException
if you like. Or you could write a wrapper around IO. But MonadError has a
functional dependency, so you can only have one error type per monad.
On Jul 14, 2016 6:19 PM, "Corentin Dupont"

I could also do my own MonadError class also, no?
However this doesn't work:
{-# LANGUAGE ConstraintKinds #-}
type EvError a = MonadError String a
class (Typeable n, Monad n, Applicative n, EvError n) => EvMgt n where ...
instance EvMgt IO where...
How can I create a new class "EvError" that inherits all the functions of
"MonadError String"?
On Fri, Jul 15, 2016 at 12:24 AM, David Feuer
You can't do that; sorry. You can always turn a string into an IOException if you like. Or you could write a wrapper around IO. But MonadError has a functional dependency, so you can only have one error type per monad.
On Jul 14, 2016 6:19 PM, "Corentin Dupont"
wrote: Hello, IO is an instance of MonadError IOException... However I also need to make it an instance of MonadError String... Is it possible? I'm trying to instanciate this class:
class (Typeable n, Monad n, Applicative n, MonadError String n) => EvMgt n where ...
instance EvMgt IO where...
Any idea?
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Type synonyms change nothing. I don't think your current line of
questioning is going to lead anywhere useful. Could you give some more
context for your original question? If you tell us what you're
ultimately trying to accomplish, someone might be able to find a way
to do it.
On Mon, Jul 18, 2016 at 9:01 AM, Corentin Dupont
I could also do my own MonadError class also, no? However this doesn't work:
{-# LANGUAGE ConstraintKinds #-}
type EvError a = MonadError String a
class (Typeable n, Monad n, Applicative n, EvError n) => EvMgt n where ...
instance EvMgt IO where...
How can I create a new class "EvError" that inherits all the functions of "MonadError String"?
On Fri, Jul 15, 2016 at 12:24 AM, David Feuer
wrote: You can't do that; sorry. You can always turn a string into an IOException if you like. Or you could write a wrapper around IO. But MonadError has a functional dependency, so you can only have one error type per monad.
On Jul 14, 2016 6:19 PM, "Corentin Dupont"
wrote: Hello, IO is an instance of MonadError IOException... However I also need to make it an instance of MonadError String... Is it possible? I'm trying to instanciate this class:
class (Typeable n, Monad n, Applicative n, MonadError String n) => EvMgt n where ...
instance EvMgt IO where...
Any idea?
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

I'm trying to define a typeclass for the management of events.
I thought it would be "nice" if IO can be an instance of it.
This would allow to manage my events in IO, as a good demonstration.
However those events can fail, so I'd like to use MonadError!
IO is an instance of MonadError IOException, but IOException is not
interesting for me since the events have other kind of exceptions.
So I see only two possibilities:
- wrap IO in a newtype, but bye-bye nice demonstration :)
- define my own error class, similar to MonadError.
Thanks!
On Mon, Jul 18, 2016 at 9:12 PM, David Feuer
Type synonyms change nothing. I don't think your current line of questioning is going to lead anywhere useful. Could you give some more context for your original question? If you tell us what you're ultimately trying to accomplish, someone might be able to find a way to do it.
On Mon, Jul 18, 2016 at 9:01 AM, Corentin Dupont
wrote: I could also do my own MonadError class also, no? However this doesn't work:
{-# LANGUAGE ConstraintKinds #-}
type EvError a = MonadError String a
class (Typeable n, Monad n, Applicative n, EvError n) => EvMgt n where
...
instance EvMgt IO where...
How can I create a new class "EvError" that inherits all the functions of "MonadError String"?
On Fri, Jul 15, 2016 at 12:24 AM, David Feuer
wrote:
You can't do that; sorry. You can always turn a string into an
IOException
if you like. Or you could write a wrapper around IO. But MonadError has a functional dependency, so you can only have one error type per monad.
On Jul 14, 2016 6:19 PM, "Corentin Dupont"
wrote: Hello, IO is an instance of MonadError IOException... However I also need to make it an instance of MonadError String... Is it possible? I'm trying to instanciate this class:
class (Typeable n, Monad n, Applicative n, MonadError String n) => EvMgt n where ...
instance EvMgt IO where...
Any idea?
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (2)
-
Corentin Dupont
-
David Feuer