Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chshersh/ghc-plugin-non-empty
đ§Ŧ GHC Plugin for compile-time transformation of list literals to NonEmpty list
https://github.com/chshersh/ghc-plugin-non-empty
compile-time ghc haskell plugin
Last synced: 8 days ago
JSON representation
đ§Ŧ GHC Plugin for compile-time transformation of list literals to NonEmpty list
- Host: GitHub
- URL: https://github.com/chshersh/ghc-plugin-non-empty
- Owner: chshersh
- License: mpl-2.0
- Created: 2022-05-01T15:19:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-11T19:13:52.000Z (almost 2 years ago)
- Last Synced: 2024-10-07T04:24:36.696Z (about 1 month ago)
- Topics: compile-time, ghc, haskell, plugin
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/ghc-plugin-non-empty
- Size: 32.2 KB
- Stars: 27
- Watchers: 3
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# ghc-plugin-non-empty
[![GitHub CI](https://github.com/chshersh/ghc-plugin-non-empty/workflows/CI/badge.svg)](https://github.com/chshersh/ghc-plugin-non-empty/actions)
[![Hackage](https://img.shields.io/hackage/v/ghc-plugin-non-empty.svg?logo=haskell)](https://hackage.haskell.org/package/ghc-plugin-non-empty)
[![MPL-2.0 license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](LICENSE)GHC Compiler Plugin for automatically converting list literals to the
`NonEmpty` type from the `Data.List.NonEmpty` module in `base`.This plugin checks statically defined list literals and transforms
them into `NonEmpty` lists during compile time. In other words, it
provides compile-time guarantees for non-emptiness checks and allows
the following expression to type-check:```haskell
portsToListen :: NonEmpty Int
portsToListen = [8000, 8080, 8081]
```Compare to usage without the plugin:
```haskell
portsToListen :: NonEmpty Int
portsToListen = 8000 :| [8080, 8081]
```> âšī¸ **DISCLAIMER:** `ghc-plugin-non-empty` is developed and
> maintained in free time by volunteers. The development may continue
> for decades or may stop tomorrow. You can use
> [GitHub Sponsorship](https://github.com/sponsors/chshersh) to support
> the development of this project.## How to use?
`ghc-plugin-non-empty` is compatible with the following GHC
versions â [supported versions](https://matrix.hackage.haskell.org/#/package/ghc-plugin-non-empty)In order to start using `ghc-plugin-non-empty` in your project, you'll
need to set it up with these steps:1. Add the dependency on `ghc-plugin-non-empty` in your project's
`.cabal` file. For this, you should modify the `build-depends`
section according to the below section:```haskell
build-depends:
, base ^>= LATEST_SUPPORTED_BASE
, ghc-plugin-non-empty ^>= LATEST_VERSION
```2. To use this package, refer to the below example.
```haskell
{-# OPTIONS_GHC -fplugin=GhcPluginNonEmpty #-}module Main (main) where
import Data.List.NonEmpty (NonEmpty)
exampleList :: NonEmpty Int
exampleList = [100, 5, 74]main :: IO ()
main = print exampleList
```## For contributors
Check [CONTRIBUTING.md](https://github.com/chshersh/ghc-plugin-non-empty/blob/main/CONTRIBUTING.md)
for contributing guidelines.To build the project and run the tests, use `cabal`:
```shell
cabal build all
cabal test --enable-tests --test-show-details=direct
```