Skip to content

Commit

Permalink
Merge pull request #22 from tfausak/2022
Browse files Browse the repository at this point in the history
Update everything for 2022
  • Loading branch information
tfausak authored Jan 8, 2022
2 parents 8c9e0ae + 41c7fc5 commit e3599f6
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 71 deletions.
4 changes: 4 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"image": "ghcr.io/tfausak/haskell-codespace:ghc-9.2",
"postCreateCommand": "cabal update"
}
10 changes: 10 additions & 0 deletions .github/workflows/brittany.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Brittany
on: push
jobs:
brittany:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: tfausak/brittany-action@v1
with:
config: config/brittany.yaml
78 changes: 58 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,76 @@ on:
types:
- created
jobs:
build:
ci:
strategy:
matrix:
include:
- { os: ubuntu-18.04, ghc: 9.2.1, cabal: 3.6.2.0 }
- { os: ubuntu-18.04, ghc: 9.0.1, cabal: 3.4.0.0 }
- { os: ubuntu-18.04, ghc: 8.10.3, cabal: 3.2.0.0 }
- { os: macos-10.15, ghc: 8.10.3, cabal: 3.2.0.0 }
- { os: windows-2019, ghc: 8.10.3, cabal: 3.2.0.0 }
- { os: ubuntu-18.04, ghc: 8.8.4, cabal: 3.0.0.0 }
runs-on: ${{ matrix.os }}
- { platform: ubuntu, ghc: 9.2.1 }
- { platform: macos, ghc: 9.2.1 }
- { platform: windows, ghc: 9.2.1, extension: .exe }
- { platform: ubuntu, ghc: 9.0.2 }
- { platform: ubuntu, ghc: 8.10.7 }
runs-on: ${{ matrix.platform }}-latest
name: GHC ${{ matrix.ghc }} on ${{ matrix.platform }}
steps:

- uses: actions/checkout@v2

- id: artifact
run: |
mkdir artifact
mkdir artifact/${{ matrix.platform }}
mkdir artifact/${{ matrix.platform }}/${{ matrix.ghc }}
echo '::set-output name=directory::artifact/${{ matrix.platform }}/${{ matrix.ghc }}'
- id: setup-haskell
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- run: cabal freeze && cat cabal.project.freeze

- run: cabal configure --enable-tests --flags pedantic --jobs

- run: cabal freeze

- run: cat cabal.project.freeze

- uses: actions/cache@v2
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.cabal }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.cabal }}-
${{ matrix.os }}-${{ matrix.ghc }}-
key: ${{ matrix.platform }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: ${{ matrix.platform }}-${{ matrix.ghc }}-

- run: cabal build

- run: cabal test --test-show-details direct
- run: cabal sdist

- run: cabal check

- run: cabal sdist --output-dir ${{ steps.artifact.outputs.directory }}

- uses: actions/upload-artifact@v2
with:
path: dist-newstyle/sdist/flow-*.tar.gz
name: flow-${{ github.sha }}.tar.gz
- run: cabal check
- if: github.event_name == 'release' && matrix.os == 'ubuntu-18.04' && matrix.ghc == '9.0.1'
run: cabal upload --publish --username '${{ secrets.HACKAGE_USERNAME }}' --password '${{ secrets.HACKAGE_PASSWORD }}' dist-newstyle/sdist/flow-*.tar.gz
path: artifact
name: flow-${{ github.sha }}

release:
needs: ci
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:

- uses: actions/download-artifact@v2
with:
name: flow-${{ github.sha }}
path: artifact

- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_content_type: application/gzip
asset_name: flow-${{ github.event.release.tag_name }}.tar.gz
asset_path: artifact/ubuntu/9.2.1/flow-${{ github.event.release.tag_name }}.tar.gz
upload_url: ${{ github.event.release.upload_url }}

- run: cabal upload --publish --username '${{ secrets.HACKAGE_USERNAME }}' --password '${{ secrets.HACKAGE_PASSWORD }}' artifact/ubuntu/9.2.1/flow-${{ github.event.release.tag_name }}.tar.gz
10 changes: 10 additions & 0 deletions .github/workflows/hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: HLint
on: push
jobs:
hlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: tfausak/hlint-action@v1
with:
config: config/hlint.yaml
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/.stack-work/
/cabal.project.freeze
/cabal.project.local*
/dist-newstyle/
/stack.yaml.lock
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"taylorfausak.purple-yolk"
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"purple-yolk.brittany.command": "brittany --config-file config/brittany.yaml --write-mode inplace",
"purple-yolk.ghci.command": "cabal repl --repl-options -ddump-json",
"purple-yolk.hlint.command": "hlint --hint config/hlint.yaml --json --no-exit-code",
"purple-yolk.hlint.onSave": true
}
4 changes: 4 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Change log

Flow follows the [Package Versioning Policy](https://pvp.haskell.org).
You can find release notes [on GitHub](https://github.com/tfausak/flow/releases).
2 changes: 1 addition & 1 deletion LICENSE.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Taylor Fausak
Copyright (c) 2022 Taylor Fausak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ understandable Haskell. It is an alternative to some common idioms like

Flow requires a Haskell compiler. It is tested with recent versions of GHC, but
older or different compilers should be acceptable. For installation with Cabal,
Flow requires at least Cabal 1.8.
Flow requires at least Cabal 2.2.

## Installation

To add Flow as a dependency to your package, add it to your Cabal file.

```
build-depends: flow ==1.0.*
build-depends: flow ==2.0.*
```

## Usage
Expand Down
4 changes: 4 additions & 0 deletions config/brittany.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
conf_layout:
lconfig_cols: 79
lconfig_columnAlignMode: { tag: ColumnAlignModeDisabled }
lconfig_indentPolicy: IndentPolicyLeft
4 changes: 4 additions & 0 deletions config/hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- group: { name: dollar, enabled: true }
- group: { name: generalise, enabled: true }
- ignore: { name: Use lambda-case }
- ignore: { name: Use tuple-section }
45 changes: 34 additions & 11 deletions flow.cabal
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
cabal-version: >= 1.10
cabal-version: 2.2

name: flow
version: 1.0.23
version: 2.0.0.0

synopsis: Write more understandable Haskell.
description: Flow provides operators for writing more understandable Haskell.

build-type: Simple
category: Combinators, Functions, Utility
extra-source-files: README.markdown
extra-source-files: CHANGELOG.markdown README.markdown
license-file: LICENSE.markdown
license: MIT
maintainer: Taylor Fausak
Expand All @@ -17,27 +17,50 @@ source-repository head
location: https://github.com/tfausak/flow
type: git

library
flag pedantic
default: False
description: Enables @-Werror@, which turns warnings into errors.
manual: True

common library
build-depends:
base >= 4.13.0 && < 4.17
, base >= 4.13.0 && < 4.17
default-language: Haskell2010
exposed-modules: Flow
ghc-options:
-Weverything
-Wno-all-missed-specialisations
-Wno-implicit-prelude
-Wno-missing-exported-signatures
-Wno-safe
hs-source-dirs: src/lib

if flag(pedantic)
ghc-options: -Werror

if impl(ghc >= 8.10)
ghc-options:
-Wno-missing-safe-haskell-mode
-Wno-prepositive-qualified-module

common executable
import: library

build-depends: flow
ghc-options:
-rtsopts
-threaded
-Wno-unused-packages

library
import: library

exposed-modules: Flow
hs-source-dirs: source/library

test-suite test
import: executable

build-depends:
base -any
, flow -any
, HUnit >= 1.6.1 && < 1.7
default-language: Haskell2010
hs-source-dirs: src/test
hs-source-dirs: source/test-suite
main-is: Main.hs
type: exitcode-stdio-1.0
2 changes: 1 addition & 1 deletion src/lib/Flow.hs → source/library/Flow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ g <. f = compose f g
--
-- prop> \ x -> compose f g x == g (f x)
compose :: (a -> b) -> (b -> c) -> (a -> c)
compose f g = \ x -> g (f x)
compose f g x = g (f x)

-- | Left-associative 'apply'' operator. Read as "strict apply forward" or
-- "strict pipe into". Use this to create long chains of computation that
Expand Down
41 changes: 41 additions & 0 deletions source/test-suite/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import qualified Control.Monad as Monad
import qualified Flow
import qualified System.Exit as Exit
import qualified Test.HUnit as Test

main :: IO ()
main = do
counts <- Test.runTestTT $ Test.TestList
[ True Test.~?= True
, (3 Flow.|> succ Flow.|> recip Flow.|> negate) Test.~?= (-0.25 :: Double)
, (negate Flow.<| recip Flow.<| succ Flow.<| 3) Test.~?= (-0.25 :: Double)
, fmap (Flow.apply 2) [succ, recip, negate] Test.~?= [3, 0.5, -2 :: Double]
, fmap (2 Flow.|>) [succ, recip, negate] Test.~?= [3, 0.5, -2 :: Double]
, fmap (2 Flow.|>) [succ, recip, negate] Test.~?= [3, 0.5, -2 :: Double]
, fmap (Flow.<| 2) [succ, recip, negate] Test.~?= [3, 0.5, -2 :: Double]
, fmap (Flow.apply 3 . Flow.compose succ) [recip, negate]
Test.~?= [0.25, -4 :: Double]
, (succ Flow..> recip Flow..> negate) 3 Test.~?= (-0.25 :: Double)
, (negate Flow.<. recip Flow.<. succ) 3 Test.~?= (-0.25 :: Double)
, fmap ((\f -> f 3) . (succ Flow..>)) [recip, negate]
Test.~?= [0.25, -4 :: Double]
, fmap ((\f -> f 3) . (succ Flow..>)) [recip, negate]
Test.~?= [0.25, -4 :: Double]
, fmap ((\f -> f 3) . (Flow.<. succ)) [recip, negate]
Test.~?= [0.25, -4 :: Double]
, (3 Flow.!> succ Flow.!> recip Flow.!> negate) Test.~?= (-0.25 :: Double)
, (undefined Flow.|> const True) Test.~?= True
, (negate Flow.<! recip Flow.<! succ Flow.<! 3) Test.~?= (-0.25 :: Double)
, (const True Flow.<| undefined) Test.~?= True
, fmap (Flow.apply' 2) [succ, recip, negate]
Test.~?= [3, 0.5, -2 :: Double]
, Flow.apply undefined (const True) Test.~?= True
, fmap (2 Flow.!>) [succ, recip, negate] Test.~?= [3, 0.5, -2 :: Double]
, fmap (2 Flow.!>) [succ, recip, negate] Test.~?= [3, 0.5, -2 :: Double]
, fmap (Flow.<! 2) [succ, recip, negate] Test.~?= [3, 0.5, -2 :: Double]
]

let
hasErrors = Test.errors counts /= 0
hasFailures = Test.failures counts /= 0
Monad.when (hasErrors || hasFailures) Exit.exitFailure
36 changes: 0 additions & 36 deletions src/test/Main.hs

This file was deleted.

0 comments on commit e3599f6

Please sign in to comment.