Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Show inferred type at point constantly #134

ghost opened this Issue · 9 comments

1 participant


At all times the user sees currently inferred type
as a comment above point.

Implementation ideas

  • Can be toggled from SublimeHaskell User settings.
  • The line uses a comment so ModuleInspector or hsdev can still work when saving.
  • Inferred type is shown in reverse order to current SublimeHaskell: Show Type command (1)
  • Cursor offset from line's beginning is added to the added comment, with adjustments so it lines with cursor (2)


Cursor is represented by a .

     -- scotty 3333 :: ScottyM () -> IO ()
     -- scotty :: Port -> ScottyM () -> IO ()
main = ◪scotty 3333 $ do

    get "/" $ do
        html . renderHtml $ do
            H.h1 "STUPID EXAMPLE"
               -- scotty 3000 :: ScottyM () -> IO ()
               -- 3000 :: Int
main = scotty 3333 $ do

    get "/" $ do
        html . renderHtml $ do
            H.h1 "STUPID EXAMPLE"
main = scotty 3333 $ do

       -- get "/" :: ActionM () -> ScottyM ()
       -- "/" :: RoutePattern
    get "◪/" $ do
        html . renderHtml $ do
            H.h1 "STUPID EXAMPLE"
main = scotty 3333 $ do

    get "/" $ do
                  -- html . renderHtml :: Html -> ActionM ()
                  -- renderHtml :: Html -> Text
        html . rende◪rHtml $ do
            H.h1 "STUPID EXAMPLE"


1 Since it will be read bottom-up the order of results should be inversed.
2 A better solution would line always with word at point as on first example, but deserves its own separate enhancement if/when this gets implemented ; )


While for writing an application showing type at the status bar would be less disruptive (a la Emacs), it means you have to scan back and forth towards bottom, and the status bar has tiny text.
(Is this option currently available?)

This is a more exploratory solution, which I think would be great to read other repositories, specially on 'point-free-addicted' libraries, or with extensive use of one of the many lens operators - I can't think of memorising them all.


What do you think, @mvoidex? If this is too far off, keeping the type on the status bar would be enough.
I'm reading the source to see how long it would take to implement something like this. Any pointers?


I think that it might be difficult to insert the types into the text, because buffer modifications will probably mess with the undo history and similar buffer features.

But give it a go - maybe you find a way!


Ah, I haven't thought about that.
I would probably need to keep a separate state and capture most buffer-related commands with a wrapper that removes and includes that type information - a somewhat ugly hack if it works.

Maybe having it at the status bar is not such a bad idea. I'll look into it.


Maybe you can also show it in a panel, like we do for error messages.

I've had some problems with panels though: E.g. did I not manage to make the text of warnings show up in a panel when the cursor is in a line with a warning - the panel API seems to be somewhat incomplete (at least in Sublime 2, haven't checked yet with 3). See #4. Maybe we can figure this out?


On Sublime Text 3 the API gained a create_output_panel(name). It mentions this:

method return type description
create_output_panel(name) View Returns the view associated with the named output panel, created it if required. The output panel can be shown by running the show_panel window command, with the panel argument set to the name with an "output." prefix.

The solution would be to fire a simplified form of show_type attached as context to captured on_text_command events.
Type would then be shown on its own panel.

To show on the status bar, show_type becomes a wrapper to a function that takes the output location, for which the legacy case is the output panel and the status bar becomes a new target.

Do you think that would work?


Maybe, but you have to try it. In Sublime 2 I had this problem:

# TODO The 'panel' key doesn't appear in the API; most probably, it is ignored,
#      and simply the current panel is hidden.
# In theory, this should work:
#     run_command('show_panel', {'panel': 'output.' + ERROR_PANEL_NAME, 'toggle': True})
# but 'toggle' doesn't seem to work on output panels (it works on the 'console' panel).
# There doesn't currently seem to be a way to close a panel by name.

I'll give it a go tomorrow at both.


I'm trying through a different path, and will get back to the panel later on. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.