Open akrmn opened 2 years ago
cc @July541, who looked a pretty-printing of stuff recently?
A quick peek: we rely on printOutputable
to print type info. I'll dive into it later.
Just wanted to add that I thought I'd check what happens when the constructor is used as a value, and to my surprise that also shows the linear arrows,
mkWrapped = MkWrapped
-- ^^^^^^^^^~ MkWrapped :: Int %1 -> WrappedInt
hovering on mkWrapped
does show the expected non-linear arrow, though.
maybeKind
if we have newtype WrappedInt = MkWrapped Int
and hover on MkWrapped
. And it is something about (AConLike (RealDataCon dataCon))
https://github.com/haskell/haskell-language-server/blob/b1bf5499155e259341e4868863b0fd743b6bd65f/ghcide/src/Development/IDE/Spans/Common.hs#L40-L49
We will get linear arrow If we print RealDataCon
directly, and it can be disabled by dataConNonlinearType
.
I Don't know how to control the printing in showSDoc
, A potential solution is reading the dynflag about lineartype to control the behavior by dataConNonlinearType
, not sure there exists a better way.
Is this still a problem?
Yes, I’m pretty sure I saw it today with hls built from master, using ghc 9.4.8
On Tue 16. 1. 2024 at 18:55, Michael Peyton Jones @.***> wrote:
Is this still a problem?
— Reply to this email directly, view it on GitHub https://github.com/haskell/haskell-language-server/issues/2904#issuecomment-1894233740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUXDJKU3MEHIGLHF47LXHTYO25KFAVCNFSM5VYFURF2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBZGQZDGMZXGQYA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I can reproduce the issue on GHC 9.4.8 + HLS 2.7.0.0
Still present; GHC-9.6.6, HLS-2.9.0.1.
This is probably confusing for newcomers and those who don't know about
LinearTypes
, even if technically correct according to the user's guideGHCi gets around this because, also according to the user's guide,
The solution, then, would be to useMkT1
-the-value for the type-on-hover tooltip, instead ofMkT1
-the-constructor.Your environment
Which OS do you use: macOS Which LSP client (editor/plugin) do you use: VSCode Describe your project (alternative: link to the project): plain cabal project, ghc-9.0.2
Steps to reproduce
Define a newtype or data type and hover on one of its constructors.
Expected behaviour
The tooltip shows the type
MkWrapped :: Int -> WrappedInt
Actual behaviour
The tooltip shows the type
MkWrapped :: Int %1 -> WrappedInt
, which includes a linear arrow.