Conversation
|
Hi, this looks interesting, but it's not clear to me why you want to avoid |
|
I think the difference is small. I am making a wrapper to -- Maybe
showDemoWindow Nothing
showDemoWindow (Just p)
-- Named
showDemoWindow ! defaults
showDemoWindow ! #p_open p
-- two functions
showDemoWindow
showDemoWindow_ p
-- Named.Varargs
showDemoWindow ()
showDemoWindow #p_open p ()
-- two instances
showDemoWindow
showDemoWindow pThe instances are written like: class ShowDemoWindow a where
showDemoWindow :: a
instance a ~ () => ShowDemoWindow (IO a) where showDemoWindowClass = raw_showDemoWindow nullPtr
instance (a ~ Ptr CUChar, b ~ IO ()) => ShowDemoWindow (a -> b) where showDemoWindow = raw_showDemoWindowThe "two instances" looks ideal, but I don't think it scales to multiple arguments. It doesn't need the |
|
Thank you for explaining your use case. What about the type signature that This is fairly straightforward to understand, there aren’t any type classes in the signature. I wouldn’t want to adopt an approach that adds more complexity to type signatures (e.g. any type variables or constraints). |
Maybe this should be exported from Named instead? Or Named.Varargs should reexport the needed parts of Named?
I would also like the equivalent of these two functions: R's ... extra arguments and R's do.call. Maybe we don't need an intermediate hlist of extra arguments. If the function wants a
va_list, perhapswithscould accept extra arguments and supply a function that applies them. In other words, I'm proposing that the following would print '3'