Skip to content

Add change type signature quick fix #2436

Closed
@jneira

Description

@jneira

When you change the body of a function and the type signature does not match you get the obvious compiler error:

F.e. for

myfunc :: String
myfunc = forM

you get

• Couldn't match type ‘t0 a0 -> (a0 -> m0 b0) -> m0 (t0 b0)’
                 with ‘[Char]’
  Expected type: String
    Actual type: t0 a0 -> (a0 -> m0 b0) -> m0 (t0 b0)
• Probable cause: ‘forM’ is applied to too few arguments
  In the expression: forM
  In an equation for ‘myfunc’: myfunc = forM

It would be nice to have a quick fix (better than a code lens imo) which changes the type signature to match the body new type, something like Change type signature to: (Traversable t, Monad m) =>t a -> (a -> m b) -> m (t b)

That type is already shown on hover.

Additional context

  • We already have a code lens to add the code signature, so this feature could reuse a lot from that one
  • That feature is common in other ides like eclipse or intellij

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions