encyclopegia.org

Uniqueness type

In computing, a unique type guarantees that an object is used in a single-threaded way, with at most a single reference to it.[src] If a value has a unique type, a function applied to it can be optimized to update the value in-place in the object code.[src] Such in-place updates improve the efficiency of functional languages while maintaining referential transparency.[src] Unique types can also be used to integrate functional and imperative programming.[src]

In computing, a unique type guarantees that an object is used in a single-threaded way, with at most a single reference to it.[src] If a value has a unique type, a function applied to it can be optimized to update the value in-place in the object code.[src] Such in-place updates improve the efficiency of functional languages while maintaining referential transparency.[src] Unique types can also be used to integrate functional and imperative programming.[src] ==Introduction== Uniqueness typing is best explained using an example.[src] Consider a function readLine that reads the next line of text from a given file: function readLine(File f) returns String return line where String line = doImperativeReadLineSystemCall(f) end end Now doImperativeReadLineSystemCall reads the next line from the file using an OS-level system call which has the side effect of changing the current position in the file.[src] But this violates referential transparency because calling it multiple times with the same argument will return different results each time as the current position in the file gets moved.[src] This in turn makes readLine violate referential transparency because it calls doImperativeReadLineSystemCall .[src] However, using uniqueness typing, we can construct a new version of readLine that is referentially transparent even though it's built on top of a function that's not referentially transparent: function readLine2(unique File f) returns (unique File, String) return (differentF, line) where String line = doImperativeReadLineSystemCall(f) File differentF = newFileFromExistingFile(f) end end The unique declaration specifies that the type of f is unique; that is to say that f may never be referred to again by the caller of readLine2 after readLine2 returns, and this restriction is enforced by the type system.[src] And since readLine2 does not return f itself but rather a new, different file object differentF , this means that it's impossible for readLine2 to be called with f as an argument ever again, thus preserving referential transparency while allowing for side effects to occur.[src] ==Programming languages== Uniqueness types are implemented in functional programming languages such as Clean, Mercury, SAC and Idris.[1] They are sometimes used for doing I/O operations in functional languages in lieu of monads.[src] A compiler extension has been developed for the Scala programming language which uses annotations to handle uniqueness in the context of message passing between actors.[1] ==Relationship to linear typing== A unique type is very similar to a linear type, to the point that the terms are often used interchangeably, but there is in fact a distinction: actual linear typing allows a non-linear value to be typecast to a linear form, while still retaining multiple references to it.[src] Uniqueness guarantees that a value has no other references to it, while linearity guarantees that no more references can be made to a value.[3] Linearity and uniqueness can be seen as particularly distinct when in relation to non-linearity and non-uniqueness modalities, but can then also be unified in a single type system.[3] ==See also== Linear type Linear logic ==References== ==External links== Bibliography on Linear Logic Uniqueness Typing Simplified[2]

21 sentences · 21 cited inline · 3 references stored

References

  1. Capabilities for uniqueness and borrowing · retrieved 2026-11-19 · rev 1293988701
    Cite this reference

    MLA "Capabilities for uniqueness and borrowing." Haller, P. 2026-11-19. https://en.wikipedia.org/wiki/Martin_Odersky. Accessed 25 November 2026.

    Chicago "Capabilities for uniqueness and borrowing." Haller, P. 2026-11-19. https://en.wikipedia.org/wiki/Martin_Odersky.

    APA Haller, P. (2026). Capabilities for uniqueness and borrowing. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/Martin_Odersky

  2. Wadler, Philip (17–19 June 1991). Is there a use for linear logic? . ACM SIGPLAN symposium on partial evaluation and semantics-based program manipulation (PEPM '91). pp. 255– 273. CiteSeerX 10.1.1.26.4202 . doi : 10.1145/115865.115894 . ISBN 0-89791-433-3 . {{ cite conference }} : Cite uses deprecated parameter |citeseerx= ( help ) Wikipedia revision 1293988701, retrieved 2026-11-20 · retrieved 2026-11-19 · rev 1293988701
    Cite this reference

    MLA "Wadler, Philip (17–19 June 1991). Is there a use for linear logic? . ACM SIGPLAN symposium on partial evaluation and semantics-based program manipulation (PEPM '91). pp. 255– 273. CiteSeerX 10.1.1.26.4202 . doi : 10.1145/115865.115894 . ISBN 0-89791-433-3 . {{ cite conference }} : Cite uses deprecated parameter |citeseerx= ( help ) Wikipedia revision 1293988701, retrieved 2026-11-20." Wadler, Philip (17–19 June 1991). 2026-11-19. https://en.wikipedia.org/wiki/Philip_Wadler. Accessed 25 November 2026.

    Chicago "Wadler, Philip (17–19 June 1991). Is there a use for linear logic? . ACM SIGPLAN symposium on partial evaluation and semantics-based program manipulation (PEPM '91). pp. 255– 273. CiteSeerX 10.1.1.26.4202 . doi : 10.1145/115865.115894 . ISBN 0-89791-433-3 . {{ cite conference }} : Cite uses deprecated parameter |citeseerx= ( help ) Wikipedia revision 1293988701, retrieved 2026-11-20." Wadler, Philip (17–19 June 1991). 2026-11-19. https://en.wikipedia.org/wiki/Philip_Wadler.

    APA Wadler, Philip (17–19 June 1991). (2026). Wadler, Philip (17–19 June 1991). Is there a use for linear logic? . ACM SIGPLAN symposium on partial evaluation and semantics-based program manipulation (PEPM '91). pp. 255– 273. CiteSeerX 10.1.1.26.4202 . doi : 10.1145/115865.115894 . ISBN 0-89791-433-3 . {{ cite conference }} : Cite uses deprecated parameter |citeseerx= ( help ) Wikipedia revision 1293988701, retrieved 2026-11-20. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/Philip_Wadler

  3. Marshall, Daniel; Vollmer, Michael; Orchard, Dominic (7 April 2022). Linearity and Uniqueness: An Entente Cordiale . ESOP'22. doi : 10.1007/978-3-030-99336-8_13 . Wikipedia revision 1293988701, retrieved 2026-11-20 · retrieved 2026-11-19 · rev 1293988701
    Cite this reference

    MLA "Marshall, Daniel; Vollmer, Michael; Orchard, Dominic (7 April 2022). Linearity and Uniqueness: An Entente Cordiale . ESOP'22. doi : 10.1007/978-3-030-99336-8_13 . Wikipedia revision 1293988701, retrieved 2026-11-20." Marshall, Daniel; Vollmer, Michael; Orchard, Dominic (7 April 2022). 2026-11-19. https://en.wikipedia.org/wiki/Doi_(identifier). Accessed 25 November 2026.

    Chicago "Marshall, Daniel; Vollmer, Michael; Orchard, Dominic (7 April 2022). Linearity and Uniqueness: An Entente Cordiale . ESOP'22. doi : 10.1007/978-3-030-99336-8_13 . Wikipedia revision 1293988701, retrieved 2026-11-20." Marshall, Daniel; Vollmer, Michael; Orchard, Dominic (7 April 2022). 2026-11-19. https://en.wikipedia.org/wiki/Doi_(identifier).

    APA Marshall, Daniel; Vollmer, Michael; Orchard, Dominic (7 April 2022). (2026). Marshall, Daniel; Vollmer, Michael; Orchard, Dominic (7 April 2022). Linearity and Uniqueness: An Entente Cordiale . ESOP'22. doi : 10.1007/978-3-030-99336-8_13 . Wikipedia revision 1293988701, retrieved 2026-11-20. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/Doi_(identifier)

Cite this article

MLA

"Uniqueness type." encyclopegia.org, 2025, https://encyclopegia.org/wiki/uniqueness-type. Accessed 25 November 2026.

Chicago

"Uniqueness type." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/uniqueness-type.

APA

encyclopegia.org. (2025). Uniqueness type. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/uniqueness-type

Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

blood type

stub · references available

Type 69 tank

stub · references available

solar-type star

stub · references available

Adobe Type

stub · references available

Audi Type B

stub · references available

Audi Type G

stub · references available

Audi Type M

stub · references available

Audi Type SS

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1293988701 · 0.5 · snapshot enwiki-001293988701

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.