Skip to content

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

Description

@yaitskov

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

Activity

  1. JordanMartinez commented on Oct 31, 2023

    @JordanMartinez
    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.

  2. garyb commented on Oct 31, 2023

    @garyb
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions