linear-base: Standard library for linear types.

[ library, mit, prelude ] [ Propose Tags ] [ Report a vulnerability ]

Please see README.md.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.8.1
Change log CHANGELOG.md
Dependencies base (>=4.16 && <5), bytestring, containers, ghc-bignum, ghc-prim, hashable, linear-base, linear-generics (>=0.2), primitive, storable-tuple, text, transformers, vector (>=0.12.2) [details]
License MIT
Copyright (c) Tweag Holding and affiliates
Author Tweag
Maintainer arnaud.spiwack@tweag.io
Uploaded by aspiwack at 2026-06-24T07:15:31Z
Category Prelude
Home page https://github.com/tweag/linear-base#README
Source repo head: git clone https://github.com/tweag/linear-base
Distributions Arch:0.7.0, LTSHaskell:0.5.0, Stackage:0.8.1
Reverse Dependencies 9 direct, 10 indirect [details]
Downloads 2591 total (19 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-06-24 [all 1 reports]

Readme for linear-base-0.8.1

[back to package description]

Linear base

License MIT Hackage Stackage Discord

Linear base is a standard library for developing applications with linear types. It is named linear-base to be an analog to the original base package that ships with GHC.

The purpose of linear-base is to provide the minimal facilities you need to write practical Linear Haskell code, i.e., Haskell code that uses the -XLinearTypes language extension.

Motivation

Why do you need linear-base to write linear projects?

  1. Data types, functions and classes in base are not linear types aware. For instance, if n is a linearly-bound Int, the RHS of a definition cannot write n + 1 — this will not type check. We need linear variants of Num, Functors, Monads, ($), etc.

  2. This library exports new abstractions that leverage linear types for resource safety or performance. For example, there are new APIs for file and socket I/O as well as for safe in-place mutation of arrays.

Getting started

-XLinearTypes is released with GHC 9, and linear-base is released on Hackage and Stackage.

All source files with linear types need a language extension pragma at the top:

{-# LANGUAGE LinearTypes #-}

To get in touch, you can join our Discord server

User Guide

If you already know what -XLinearTypes does and what the linear arrow a %1-> b means, then read the User Guide and explore the examples/ folder to know how to use linear-base.

You can also find a table comparing base and linear-base typeclasses here.

Learning about -XLinearTypes

If you're a Haskeller who hasn't written any Linear Haskell code, don't fear! There are plenty of excellent resources and examples to help you.

Tutorials and examples

Reading material

Talks

–

Contributing

Linear base is maintained by Tweag.

To contribute please see the Design Document for instructions and advice on making pull requests.

A great first step is to join our Discord server

Licence

See the Licence file.

Copyright © Tweag Holding and its affiliates.