Skip to content

Commit

Permalink
Add a Nix flake
Browse files Browse the repository at this point in the history
This removes the pre-flake Nix support as well as Stack support.

It also moves some jobs from GitHub CI to Garnix – namely, any ghc version that
nixpkgs contains, plus hlint and ormolu.
  • Loading branch information
sellout committed Jul 8, 2023
1 parent 404a1c0 commit cc84a9d
Show file tree
Hide file tree
Showing 21 changed files with 734 additions and 129 deletions.
4 changes: 4 additions & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
((nil
(fill-column . 80)
(indent-tabs-mode . nil)
(sentence-end-double-space . nil)))
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### This configures basic cross-editor formatting.
###
### See https://editorconfig.org/ for more info, and to see if your editor
### requires a plugin to take advantage of it.

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{diff,patch}]
trim_trailing_whitespace = false

[*.{el,lisp}]
## Lisps have a fairly consistent indentation style that doesn’t collapse well
## to a single value, so we let the editor do what it wants here.
indent_size = unset
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use nix
use flake
18 changes: 1 addition & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
- "8.6.1"
- "8.8.1"
- "8.10.1"
- "8.10.7" # we have explicit conditionalization for this version
- "9.0.1"
- "9.2.1"
- "9.4.1"
env:
CONFIG: "--enable-tests --enable-benchmarks"
steps:
Expand All @@ -37,19 +37,3 @@ jobs:
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
- run: cabal v2-test all $CONFIG
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: mrkkrp/ormolu-action@v5
lint:
# Change to `ubuntu-latest` once rwe/actions-hlint-run#260 is fixed.
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: rwe/actions-hlint-setup@v1
with:
version: '3.3.6'
- uses: rwe/actions-hlint-run@v2
with:
fail-on: status
32 changes: 10 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
dist
dist-*
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*
# Direnv
/.direnv

# Nix build
/outputs
/result
/source

# Cabal build
dist-newstyle
40 changes: 40 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- ignore: {name: "Eta reduce"}
- ignore: {name: "Evaluate"}
- ignore: {name: "Reduce duplication"}
- ignore: {name: "Use list comprehension"}
- ignore: {name: "Use section"}

- package:
name: monad
modules:
- import Control.Monad

- package:
name: traversable
modules:
- import Data.Foldable
- import Data.Traversable

- group:
name: generalize
imports:
- package monad
- package traversable
rules:
- warn: {lhs: forM, rhs: for}
- warn: {lhs: forM_, rhs: for_}
- warn: {lhs: map, rhs: fmap}
- warn: {lhs: mapM, rhs: traverse}
- warn: {lhs: mapM_, rhs: traverse_}
- warn: {lhs: return, rhs: pure}
- warn: {lhs: sequence, rhs: sequenceA}
- warn: {lhs: sequence_, rhs: sequenceA_}

- group:
name: generalize
imports:
- package traversable
rules:
- hint: {lhs: maybe (pure ()), rhs: traverse_, note: IncreasesLaziness}
- warn: {lhs: mappend, rhs: (<>)}
- warn: {lhs: (++), rhs: (<>)}
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Yet another … yet another recursion scheme library for Haskell.

## Overview
## overview

Recursion schemes allow you to separate _any_ recursion from your business logic, writing step-wise operations that can be applied in a way that guarantees termination (or, dually, progress).

Expand All @@ -14,10 +14,40 @@ How is this possible? You can’t have totality _and_ Turing-completeness, can y
* [`yaya-hedgehog`](hedgehog/README.md) – utilities for testing your Yaya-using code with [Hedgehog](https://github.com/hedgehogqa/haskell-hedgehog)
* [`yaya-unsafe`](unsafe/README.md) – unsafe instances and operations

## other libraries
## versioning

In the absolute, almost every change is a breaking change. This section describes how we mitigate that to provide minor updates and revisions compatible with [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html).

Here are some of the common changes that can have unintended effects:
* adding instances can conflict with downstream orphans,
* adding a module can conflict with a module from another package,
* adding a definition to an existing module can conflict if there are unqualified imports, and
* even small bugfixes can introduce breaking changes where downstream depended on the broken results.

To mitigate some of those issues for versioning, we assume the following usage:
* modules should be imported using `PackageImports`, so that adding modules is a _minor_ change;
* modules should be imported qualified, so that adding definitions is a _minor_ change;
* adding instances can't be mitigated in the same way, and it's not uncommon for downstream libraries to add orphans instances when they're omitted from upstream libraries. However, since these conflicts can only happen via direct dependencies, and represent an explicit downstream workaround, it is reasonable to expect a quick downstream update to remove or conditionalize the workaround. So, this is considered a _minor major_ change;
* deprecation is considered a _revision_ change, however it will often be paired with _minor_ changes. `-Werror` can cause this to fail, but published libraries shouldn't be compiled with `-Werror`.

## building & development

### if you have `nix` installed

`nix build` will build and test the project fully.

`nix develop` will put you into an environment where the traditional build tooling works. If you also have `direnv` installed, then you should automatically be in that environment when you're in a directory in this project.

### traditional build

This project is built with [Cabal](https://cabal.readthedocs.io/en/stable/index.html). Individual packages will work with older versions, but ./cabal.package requires Cabal 3.6+.

## comparisons

### [Turtles](https://github.com/sellout/turtles)

**This project has been deprecated. Check out [Droste](https://github.com/higherkindness/droste) instead.**

Yaya is a sister library to Turtles – the same approach, but implemented in
Scala. Here are some differences to be aware of:

Expand All @@ -30,7 +60,7 @@ Scala. Here are some differences to be aware of:
`Data.List` is lazy, so the `Corecursive` instance is in `Native` while the
`Recursive` instance is in `Unsafe`.

### Differences from [recursion-schemes](https://github.com/ekmett/recursion-schemes)
### [recursion-schemes](https://github.com/ekmett/recursion-schemes)

#### poly-kinded folds

Expand Down Expand Up @@ -114,7 +144,7 @@ different situations, so we try to avoid pigeon-holing them and rather trying to
understand what the definition itself means, rather than in the context of a
fold.

### Differences from [compdata](https://github.com/pa-ba/compdata)
### [compdata](https://github.com/pa-ba/compdata)

Im not as familiar with compdata, so Ill have to look at it more before
fleshing this out.
Expand Down
12 changes: 7 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
tests: True

packages:
./core/yaya.cabal
./core-test/yaya-test.cabal
./hedgehog/yaya-hedgehog.cabal
./unsafe/yaya-unsafe.cabal
./unsafe-test/yaya-unsafe-test.cabal
./core/yaya.cabal
./core-test/yaya-test.cabal
./hedgehog/yaya-hedgehog.cabal
./unsafe/yaya-unsafe.cabal
./unsafe-test/yaya-unsafe-test.cabal
5 changes: 5 additions & 0 deletions core-test/yaya-test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ tested-with: GHC == 8.6.1
, GHC == 8.10.1
, GHC == 8.10.7
, GHC == 9.0.1
, GHC == 9.0.2
, GHC == 9.2.1
, GHC == 9.2.8
, GHC == 9.4.1
, GHC == 9.4.5
, GHC == 9.6.1

test-suite yaya-test
type: exitcode-stdio-1.0
Expand Down
5 changes: 5 additions & 0 deletions core/yaya.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ tested-with: GHC == 8.6.1
, GHC == 8.10.1
, GHC == 8.10.7
, GHC == 9.0.1
, GHC == 9.0.2
, GHC == 9.2.1
, GHC == 9.2.8
, GHC == 9.4.1
, GHC == 9.4.5
, GHC == 9.6.1

library
hs-source-dirs: src
Expand Down
9 changes: 0 additions & 9 deletions default.nix

This file was deleted.

Loading

0 comments on commit cc84a9d

Please sign in to comment.