Skip to content

Type-on-hover for type constructors shows linear arrows even if -XLinearTypes is not enabled #2904

Open
@akrmn

Description

@akrmn

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, MkT1 is given a multiplicity-polymorphic type: MkT1 :: forall {m} a. a %m -> T1 a. [...] When displaying types, unless -XLinearTypes is 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 Int

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GHCissues with particular GHC versionscomponent: ghcidetype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions