[Haskell-cafe] Problem with existential type and instance.
Magicloud Magiclouds
magicloud.magiclouds at gmail.com
Mon Jul 28 07:50:05 UTC 2014
I see. Thank you.
Any anyway I could use (MonadIO m) here, in Nothing data type?
On Mon, Jul 28, 2014 at 3:47 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
> * Magicloud Magiclouds <magicloud.magiclouds at gmail.com> [2014-07-28
> 13:46:53+0800]
> > Hi,
> >
> > For code like below, how to make it compilable?
> >
> > data EventHandlers = forall m. MonadIO m => EventHandlers {
> onDeleteWindow
> > :: Maybe (m ()) }
> > instance Default EventHandlers where
> > def = EventHandlers Nothing
>
> GHC has to store some MonadIO dictionary in the existential type, but it
> cannot
> figure out which dictionary to store (it can be any).
>
> You can tell it which one to use by supplying a type annotation, e.g.:
>
> def = EventHandlers (Nothing :: Maybe (IO ()))
>
> Roman
>
--
竹密岂妨流水过
山高哪阻野云飞
And for G+, please use magiclouds#gmail.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140728/31c110e9/attachment.html>
More information about the Haskell-Cafe
mailing list