-
-
Notifications
You must be signed in to change notification settings - Fork 430
Description
This is probably confusing for newcomers and those who don't know about LinearTypes, even if technically correct according to the user's guide
By default, all fields in algebraic data types are linear
-- https://downloads.haskell.org/ghc/9.0.2/docs/html/users_guide/exts/linear_types.html#data-types
GHCi gets around this because, also according to the user's guide,
[...] Given
data T1 a = MkT1 a[...] [w]hen used as a value,MkT1is given a multiplicity-polymorphic type:MkT1 :: forall {m} a. a %m -> T1 a. [...] When displaying types, unless-XLinearTypesis enabled, multiplicity polymorphic functions are printed as regular functions [...]; therefore constructors appear to have regular function types.
-- https://downloads.haskell.org/ghc/9.0.2/docs/html/users_guide/exts/linear_types.html#data-types
The solution, then, would be to use MkT1-the-value for the type-on-hover tooltip, instead of MkT1-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.
newtype WrappedInt = MkWrapped IntExpected 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.