[Haskell-cafe] How to "instance MonadIO Identity"?
michael at snoyman.com
Tue Dec 28 06:56:57 CET 2010
Well, you *could* use unsafePerformIO on getSystemEncoding, though I'm
not familiar with getSystemEncoding, so I can't tell you whether this
is an acceptable usage of unsafePerformIO.
On Tue, Dec 28, 2010 at 7:47 AM, Magicloud Magiclouds
<magicloud.magiclouds at gmail.com> wrote:
> Ah, that is a bad news.
> I am using Control.Monad.Writer and Data.Encoding. Code like (not compilable)
> 43|instance WithMessage String where
> 44| append s = (liftIO $ getSystemEncoding) >>= (\e -> tell $
> encodeLazyByteString e s)
> May I know how to make this work?
> 2010/12/28 Michael Snoyman <michael at snoyman.com>:
>> The only way to create such an instance would be with unsafePerformIO,
>> which in this case would be a Very Bad Idea (tm).
>> On Tue, Dec 28, 2010 at 7:29 AM, Magicloud Magiclouds
>> <magicloud.magiclouds at gmail.com> wrote:
>>> From another thread in this list, I got code as:
>>>> instance MonadIO Identity where
>>>> liftIO = id
>>> Well, it does not work for me as:
>>> Couldn't match expected type `Identity a' with actual type `IO a'
>>> Expected type: IO a -> Identity a
>>> Actual type: IO a -> IO a
>>> In the expression: id
>>> In an equation for `liftIO': liftIO = id
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe