jcollard / elm-mode

Elm mode for emacs
GNU General Public License v3.0
376 stars 67 forks source link

Show the type at point doesn't work with user defined values #124

Closed welf closed 7 years ago

welf commented 7 years ago

It is a feature request.

Show the type of the function at point in the minibuffer currently works only with functions and values defined in imported libraries. If the user defines his own function or variable C-c C-t gives us a message Unknown type. C-c C-a inserts the right type signature, so I think it will be not difficult to add show type at point function to user-defined functions and variables.

It is sometimes also useful to see the type of the highlighted expression. In Haskell, I frequently use it to see which type the expression has because it helps to write complex functions.

purcell commented 7 years ago

The info for C-c C-t comes from elm-oracle, which doesn't know how to parse the user's Elm code, so it only supports functions/types in imported libraries. The type sig for C-c C-a is obtained by running the Elm compiler, which then complains about the missing type signature: that complaint is parsed in order to insert the type.

So in summary, there's not really any backend machinery to request this information of, sorry.