`Data.Functor.void` needs a way to specify the type of discarded value
yaitskov opened this issue · comments
I have following code snippet:
post :: forall m a. DecodeJson a => Monad m => String -> m a
deleteFoo = do
void $ post "http://localhost/delete"
type checker complains with:
No type class instance was found for
Data.Argonaut.Encode.Class.DecodeJson t3
Current version of void
function cannot get type parameter:
deleteFoo = do
void @Unit $ post "http://localhost/delete"
An expression of polymorphic type
with the invisible type variable f:
forall f a. Functor f => f a -> f Unit
cannot be applied to:
Boolean
I suggest to rewrite void
function to make it more flexible:
voidAt :: forall @a f . Functor f => f a -> f Unit
voidAt = void
I suggest to rewrite void function to make it more flexible:
Is post
code you control? Or from something else? post
could also use a VTA arg to make this
void $ post @Unit "url"
And void
would likely be updated to void @f
first and possibly void @f @a
since usually the f
is more often the thing to specify than that a
.
I would agree that this seems more like something that should be solved at post
- I think when designing APIs I'd only be using VTAs to dictate values that are produced - it would never even occur to me to use them to dictate the input to a function, since I think of inference working that way around.