Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data.Functor.void needs a way to specify the type of discarded value #308

Open
yaitskov opened this issue Oct 31, 2023 · 2 comments
Open

Comments

@yaitskov
Copy link

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
@JordanMartinez
Copy link
Contributor

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.

@garyb
Copy link
Member

garyb commented Oct 31, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants