Need help with linear-base?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

tweag
206 Stars 14 Forks MIT License 662 Commits 36 Opened issues

Description

Standard library for linear types in Haskell.

Services available

!
?

Need anything else?

Contributors list

Linear base

License MIT Build status

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
    ,
    Functor
    s,
    Monad
    s,
    ($)
    , 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.

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

{-# LANGUAGE LinearTypes #-}

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
.

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

– * 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.

Licence

See the Licence file.

Copyright © Tweag Holding and its affiliates.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.