登录 注册

linear-base

去点 Star
开发者工具AI 模型与开发框架内容创作与媒体工具 haskelllinear-types
361
Stars
45
Forks
31
Watchers
56
Open Issues
MIT
许可证
Haskell
语言
2017-11-23
创建时间
2026-10-30
最近更新

项目能做什么

**linear-base** 是面向 Haskell 线性类型(`-XLinearTypes`)的标准库。因原生 `base` 库不支持线性绑定,该项目提供了支持线性类型的 `Num`、`Monad` 等基础类型类与函数替代版,并提供文件/Socket I/O 及数组安全原地修改等抽象,用于保障资源安全与提升性能。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Linear base

[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/tweag/linear-base/blob/master/LICENSE)
[![Hackage](https://img.shields.io/hackage/v/linear-base.svg?style=flat&color=brightgreen)][hackage-pkg]
[![Stackage](https://stackage.org/package/linear-base/badge/nightly)][stackage-pkg]
[![Discord](https://img.shields.io/badge/Discord-100000?style=flat&logo=Discord&logoColor=C3C3C3&labelColor=4179DA&color=010101)][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`, `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][hackage-pkg] and [Stackage][stackage-pkg].

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](https://img.shields.io/badge/Discord-100000?style=flat&logo=Discord&logoColor=C3C3C3&labelColor=4179DA&color=010101)][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/`](https://github.com/tweag/linear-base/blob/master/examples) folder to know how to use `linear-base`.

You can also find a table comparing `base` and `linear-base` typeclasses
[here](https://github.com/tweag/linear-base/blob/master/docs/CLASS_TABLE.md).

## 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/`](https://github.com/tweag/linear-base/blob/master/examples) folder.
 * [Linear examples on watertight 3D models](https://github.com/gelisam/linear-examples)

### Reading material

  * There is a [wiki page](https://gitlab.haskell.org/ghc/ghc/-/wikis/linear-types).
  * Key Blog posts
    * [Predictable performance](https://www.tweag.io/posts/2017-03-13-linear-types.html) (the first blog post from Tweag on this)
    * [IO State Transitions](https://www.tweag.io/posts/2017-08-03-linear-typestates.htm
阅读完整原文

项目深度分析 AI 生成

高性能高可靠系统咨询与架构审计服务

产品构想基于 linear-base 为使用 Haskell 的金融科技或区块链企业提供零内存拷贝、严格资源析构(避免句柄/内存泄漏)的架构优化与代码审计服务。
核心功能利用线性类型保证的资源生命周期静态检查服务、就地数组更新与零拷贝 I/O 架构设计、性能瓶颈剖析与定制改造方案。
目标用户使用 Haskell 的量化金融机构、区块链核心开发团队、关键任务系统工程主管。
难度/周期高 · 3 - 6 个月 · 成本:人力成本高(需深入理解 GHC 内部机制、LinearTypes 原理及复杂工程实践)
收费模式按企业咨询项目结算或按工时/技术顾问年费计费。
竞争风险Haskell 商业受众极窄,市场潜在买家数量有限;传统 Haskell 开发者对线性类型上手门槛极高。
依据 已验证事实

线性安全型网络/数据通信驱动库 (商业扩展套件)

产品构想构建并销售基于 linear-base 的高性能、零安全漏洞的商业通信中间件(例如专用零拷贝协议解析器、高吞吐内存池管理工具)。
核心功能基于线性类型的防协议状态错乱机制(Typestate Pattern)、确定性垃圾回收绕过机制、开箱即用的高性能协议栈(如 Fix/WebSocket 等)。
目标用户需要超低延迟、强类型安全保障的分布式系统后端开发者。
难度/周期极高 · 6 - 12 个月 · 成本:深层底层研发成本,持续的性能基准测试与兼容性维护成本。
收费模式双重许可(Dual-License)销售商业私有授权,或提供带 SLA 的企业支持版。
竞争风险替代生态丰富(如 Rust 已经天然具备所有权模型,Haskell 开发者可能倾向直接调用 FFI/C/Rust 而非纯 Haskell 线性类型方案)。
依据 AI推测

企业级 Linear Haskell 培训与工程落地课程

产品构想制作面向中高级 Haskell 团队的“-XLinearTypes 实战工程化”培训课程与内训工作坊,加速技术团队掌握安全类型系统。
核心功能结合 linear-base 的真实场景演练(安全 I/O、数组就地修改、资源状态机模型)、企业内训答疑、配套课件及调试指导。
目标用户拥有成熟 Haskell 研发团队的科技公司、计算机系研究所及函数式编程极客。
难度/周期中等 · 1 - 2 个月 · 成本:主要是课程设计与案例构建的工时成本。
收费模式B端企业内训采购费用、高级专业在线课程订阅/买断费用。
竞争风险目标受众绝对规模过小,可能无法支撑持续性的独立收入规模。
依据 数据支持的判断
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

相似项目数据正在完善中,暂不展示(避免误导)

项目优势与风险

技术成熟度创建于 2017-11-23,近 30 天仍在推送,发布过 10 个 Release
社区活跃Star 361 / Fork 45 / Issue 56(数据支持,可自行核实)
许可证MIT
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。