| CARVIEW |
linear-base: Standard library for linear types.
Modules
[Index] [Quick Jump]
- Control
- Functor
- Control.Functor.Linear
- Internal
- Control.Functor.Linear.Internal.Class
- Control.Functor.Linear.Internal.Instances
- Control.Functor.Linear.Internal.Kan
- Control.Functor.Linear.Internal.MonadTrans
- Control.Functor.Linear.Internal.Reader
- Control.Functor.Linear.Internal.State
- Internal
- Control.Functor.Linear
- Monad
- Optics
- Functor
- Data
- Arity
- Data.Arity.Linear
- Data.Arity.Linear.Internal
- Data.Arity.Linear
- Array
- Data.Array.Destination
- Data.Array.Destination.Internal
- Mutable
- Data.Array.Mutable.Linear
- Data.Array.Mutable.Linear.Internal
- Unlifted
- Data.Array.Mutable.Linear
- Data.Array.Polarized
- Data.Array.Polarized.Pull
- Data.Array.Polarized.Pull.Internal
- Data.Array.Polarized.Push
- Data.Array.Polarized.Pull
- Data.Array.Destination
- Bifunctor
- Data.Bifunctor.Linear
- Internal
- Data.Bifunctor.Linear.Internal.Bifunctor
- Data.Bifunctor.Linear.Internal.SymmetricMonoidal
- Internal
- Data.Bifunctor.Linear
- Bool
- Either
- Functor
- Data.Functor.Linear
- Internal
- Data.Functor.Linear.Internal.Applicative
- Data.Functor.Linear.Internal.Functor
- Data.Functor.Linear.Internal.Traversable
- Internal
- Data.Functor.Linear
- HashMap
- Mutable
- Data.HashMap.Mutable.Linear
- Data.HashMap.Mutable.Linear.Internal
- Data.HashMap.Mutable.Linear
- Mutable
- List
- Maybe
- Monoid
- Data.Monoid.Linear
- Internal
- Data.Monoid.Linear.Internal.Monoid
- Data.Monoid.Linear.Internal.Semigroup
- Internal
- Data.Monoid.Linear
- Num
- Ord
- Data.Ord.Linear
- Internal
- Data.Ord.Linear.Internal.Eq
- Data.Ord.Linear.Internal.Ord
- Internal
- Data.Ord.Linear
- Profunctor
- Replicator
- Data.Replicator.Linear
- Data.Replicator.Linear.Internal
- Data.Replicator.Linear.Internal.Instances
- Data.Replicator.Linear.Internal.ReplicationStream
- Data.Replicator.Linear.Internal
- Data.Replicator.Linear
- Set
- Mutable
- Data.Set.Mutable.Linear
- Data.Set.Mutable.Linear.Internal
- Data.Set.Mutable.Linear
- Mutable
- Tuple
- Unrestricted
- Data.Unrestricted.Linear
- Internal
- Data.Unrestricted.Linear.Internal.Consumable
- Data.Unrestricted.Linear.Internal.Dupable
- Data.Unrestricted.Linear.Internal.Instances
- Data.Unrestricted.Linear.Internal.Movable
- Data.Unrestricted.Linear.Internal.Ur
- Data.Unrestricted.Linear.Internal.UrT
- Internal
- Data.Unrestricted.Linear
- V
- Data.V.Linear
- Data.V.Linear.Internal
- Data.V.Linear.Internal.Instances
- Data.V.Linear.Internal
- Data.V.Linear
- Vector
- Mutable
- Data.Vector.Mutable.Linear
- Data.Vector.Mutable.Linear.Internal
- Data.Vector.Mutable.Linear
- Mutable
- Arity
- Debug
- Trace
- Foreign
- Marshal
- Foreign.Marshal.Pure
- Foreign.Marshal.Pure.Internal
- Foreign.Marshal.Pure
- Marshal
- Prelude
- Streaming
- Streaming.Linear
- Internal
- Streaming.Linear.Internal.Consume
- Streaming.Linear.Internal.Interop
- Streaming.Linear.Internal.Many
- Streaming.Linear.Internal.Process
- Streaming.Linear.Internal.Produce
- Streaming.Linear.Internal.Type
- Internal
- Prelude
- Streaming.Linear
- System
- IO
- System.IO.Linear
- Resource
- System.IO.Resource.Linear
- System.IO.Resource.Linear.Internal
- System.IO.Resource.Linear
- IO
- Unsafe
Downloads
- linear-base-0.6.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
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 |
|---|---|
| Change log | CHANGELOG.md |
| Dependencies | base (>=4.16 && <5), 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 2025-11-18T12:29: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.5.0, LTSHaskell:0.5.0, NixOS:0.5.0, Stackage:0.6.0 |
| Reverse Dependencies | 7 direct, 10 indirect [details] |
| Downloads | 2317 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 2025-11-18 [all 1 reports] |
Readme for linear-base-0.6.0
[back to package description]Linear base
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?
-
Data types, functions and classes in
baseare not linear types aware. For instance, ifnis a linearly-boundInt, the RHS of a definition cannot writen + 1— this will not type check. We need linear variants ofNum,Functors,Monads,($), etc. -
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
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
- See the
examples/folder. - Linear examples on watertight 3D models
Reading material
- There is a wiki page.
- Key Blog posts
- Predictable performance (the first blog post from Tweag on this)
- IO State Transitions
- Streaming
- See here for all of Tweag's blog posts on linear types.
- Here is the paper behind
-XLinearTypes.
Talks
–
- Distributed Programming with Linear Types – Haskell Exchange 2017
- Practical Linearity in a higher-order polymorphic language – POPL 2018
- Practical Linearity in a higher-order polymorphic language – Curry on 2018
- Practical Linearity in a higher-order polymorphic language – Haskell Exchange 2018
- Implementing Linear Haskell
- In-place array update with linear types – ZuriHac 2020
- Typecheck Your Memory Management with Linear Types – Haskell Exchange 2017
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
server
Licence
See the Licence file.
Copyright © Tweag Holding and its affiliates.