I am creating a way to display dialogue to users.
data DialogConfig tmbe = DialogConfig { _dialogConfig_title :: Dynamic t T.Text , _dialogConfig_content :: b -> m (Dynamic t (Maybe b)) , _dialogConfig_footer :: Dynamic t (Maybe b) -> m (Event te) } dialog :: MonadWidget tm => DialogConfig tmbe -> Event tb -> m (Event t (DialogEvent e))
I would like to use some kind of "default" instance to initialize DialogConfig for the dialog function so that I can use it, for example. defaultConfig{_dialogConfig_content=content} . However, I am struggling with the type of inferrence. It works:
confirmDialog :: forall t m. MonadWidget tm => T.Text -> Event t T.Text -> m (Event t ()) ... evt <- dialog (DialogConfig { _dialogConfig_title = constDyn title , _dialogConfig_content = content , _dialogConfig_footer = buttons} ) contentEvt
However, when I use some default DialogConfig (for example, directly inserting it here), it does not execute:
evt <- dialog (DialogConfig { _dialogConfig_title = constDyn mempty , _dialogConfig_content = const $ return $ constDyn Nothing , _dialogConfig_footer = const $ return never } { _dialogConfig_title = constDyn title , _dialogConfig_content = content , _dialogConfig_footer = buttons} ) contentEvt
Errors:
Could not deduce (Reflex t0) arising from a use of 'constDyn' from the context (MonadWidget tm) Could not deduce (Monad t1) arising from a use of 'return' from the context (MonadWidget tm)
I can use ScopedTypeVariables and enter the default configuration in confirmDialog as DialogConfig tmab , and this works, but shouldn't it work even without it? It seems to me that the types are pretty straightforward.
source share