Skip to content

Font-lock types differently #899

Closed
Closed
@gracjan

Description

@gracjan

Types and constructors share namespace in Haskell and only context tell how a token starting with uppercase letter should be interpreted. Emacs' font lock isn't best at context but can be coerced to use one. The plan:

  1. Trigger type font lock on :: token.
  2. Parse what comes after that as a type expression.
  3. Mark where the type expression starts and ends.
  4. Font lock tokens in marked region as types instead of constructors.

Tricky situations:

putStrLn (123 :: Int)
x :: String <- return ""
x :: String = "xx"
x :: (HasField "field" r) => r
x + y :: Int where y = 45
data T = C

And everything related to DataKinds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions