hls-alternate-number-format-plugin: Provide Alternate Number Formats plugin for Haskell Language Server

[ apache, development, library ] [ Propose Tags ]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,,,,,,,
Dependencies aeson, base (>=4.12 && <5), containers, extra, ghc-boot-th, ghcide (>=1.10 && <1.11), hie-compat, hls-graph, hls-plugin-api (>=1.6 && <1.7), lens, lsp (>=1.6 && <1.7), mtl, regex-tdfa, syb, text, unordered-containers [details]
License Apache-2.0
Author Nick Suchecki
Maintainer nicksuchecki@gmail.com
Revised Revision 1 made by hls_team at 2023-05-17T12:16:27Z
Category Development
Source repo head: git clone https://github.com/haskell/haskell-language-server.git
Uploaded by hls_team at 2023-03-31T05:33:51Z
Distributions Arch:
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3164 total (60 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-03-31 [all 1 reports]

Readme for hls-alternate-number-format-plugin-

[back to package description]

Alternate Number Format Plugin

The alternate number format plugin provides alternative formatting for Numeric Literals in source code. These can be any numeric literal such as 123, 0x45 or any of the other numeric formats. The Code Action will provide all possible formatting suggestions (and when required insert the associated Language Extension)


The plugin requires no extra setup to work. Simply place your cursor on top of a literal and invoke the codeAction command for your editor.


Alternate format suggestions

Currently Supported GHC Extensions:

  • BinaryLiterals
  • HexFloatLiterals
  • NumDecimalLiterals


The plugin is relatively simple, it traverses a files source contents using the GHC API. As it encounters Literals (of the type HsExpr with the constructor of either HsLit or HsOverLit), it will construct an internal Literal datatype that has additional information for use to generate suggestions. Currently, the traversal is done in the file, Literal.hs, using the package SYB for most of the heavy lifting.

To generate suggestions, the plugin leverages the Numeric package which provides a multitude of conversion functions to and from strings/numerics.

Known Quirks

  • Anything that produces a bad Source Span (i.e. can't be easily replaced by an edit) is ignored as well.


  • First Release

  • Dependency upgrades

  • Buildable with GHC 9.2

  • Test Suite upgraded for 9.2 semantics (GHC2021)
  • Fix SYB parsing with GHC 9.2

  • Provide ALL possible formats as suggestions
  • Insert Language Extensions when needed