symbol: A 'Symbol' type for fast symbol comparison.

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

Provides a Symbol data type allowing fast symbol comparisons and functions for interning symbols and recovering their String representation.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1, 0.1.1, 0.1.1.1, 0.1.2, 0.1.2.1, 0.1.3, 0.1.4, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.4.1, 0.3.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), containers (>=0.2 && <0.9), deepseq (>=1.0 && <2) [details]
Tested with ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.3, ghc ==8.6.5, ghc ==8.8.4, ghc ==8.10.7, ghc ==9.0.2, ghc ==9.2.2, ghc ==9.4.8, ghc ==9.6.4, ghc ==9.8.2, ghc ==9.10.1, ghc ==9.12.4, ghc ==9.14.1
License BSD-3-Clause
Copyright (c) 2006-2011 Harvard University (c) 2011-2026 Geoffrey Mainland
Author Geoffrey Mainland <mainland@drexel.edu>
Maintainer Geoffrey Mainland <mainland@drexel.edu>
Uploaded by GeoffreyMainland at 2026-09-11T18:37:27Z
Category Data
Home page https://github.com/mainland/symbol
Source repo head: git clone https://github.com/mainland/symbol.git
Distributions LTSHaskell:0.2.4.1, Stackage:0.3.0
Reverse Dependencies 11 direct, 41 indirect [details]
Downloads 18155 total (32 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-09-11 [all 1 reports]

Readme for symbol-0.3.0

[back to package description]

The symbol Package Hackage Actions Status: haskell-ci

Provides a Symbol data type allowing fast symbol comparisons and functions for interning symbols and recovering their String representation.

import Data.Symbol (intern, unintern)

intern "name" == intern "name"  -- True
unintern (intern "name")        -- "name"

Symbols created through intern compare equal exactly when their strings do. Equality and ordering compare integer identifiers in constant time. Ordering follows identifier allocation, rather than lexicographic string order, and can vary with evaluation order and between runs. For lexicographic ordering, compare the strings returned by unintern.

Interning uses a synchronized, process-wide table. Every distinct interned string and its symbol remain in that table for the lifetime of the process, even after the caller drops all references. Memory use therefore grows with the number and total size of distinct strings interned. intern fully evaluates its input string before accessing the table. Inputs must be finite and fully defined.

The Data instance exposes a Symbol constructor with one String field. Generic construction and transformations call intern, preserving symbol identity. Use Data.Symbol for the abstract API. Data.Symbol.Unsafe exposes the raw constructor, which can break the association between identifiers and strings.

To build and run the test suite:

cabal build all
cabal test all --test-show-details=direct

The package supports GHC 8.0 and later. CI tests the versions listed in symbol.cabal; regenerate the workflow with haskell-ci regenerate after changing that list or the package components.

Formatting uses .stylish-haskell.yaml. With the VS Code Haskell extension and a working Haskell Language Server, the workspace settings enable formatting on save. To format from the command line:

stylish-haskell -i Setup.hs src/Data/Symbol.hs src/Data/Symbol/Unsafe.hs tests/Main.hs