
I think that is what I need. Thanks.
On Mon, Jul 28, 2014 at 4:04 PM, Roman Cheplyaka
What do you mean? MonadIO m is a constraint. You have to supply some type that satisfies this constraint. IO is one such type; you could use any other.
Alternatively, if you *don't* want to store a MonadIO dictionary in the Nothing case, create your own Maybe type:
data MaybeMonadIO = NoMonadIO | forall m . MonadIO m => JustMonadIO (m ())
newtype EventHandlers = EventHandlers { onDeleteWindow :: MaybeMonadIO }
* Magicloud Magiclouds
[2014-07-28 15:50:05+0800] 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
wrote: * Magicloud Magiclouds
[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.
-- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com.