mirror of
https://github.com/coot/free-category.git
synced 2024-11-25 05:36:04 +03:00
Support GHC: 9.0, 9.2, 9.4
Drop support for GHC 8.6 or earlier. Remove nix.
This commit is contained in:
parent
da3aa0cd33
commit
75c64698bb
6
.github/workflows/cabal.project.local
vendored
Normal file
6
.github/workflows/cabal.project.local
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
documentation: True
|
||||||
|
tests: True
|
||||||
|
benchmarks: True
|
||||||
|
|
||||||
|
package free-category
|
||||||
|
ghc-options: -j2 -Werror
|
87
.github/workflows/ci.yaml
vendored
Normal file
87
.github/workflows/ci.yaml
vendored
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
name: Haskell CI
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ghc: ["8.8.4", "8.10.7", "9.0.2", "9.2.4", "9.4.2"]
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install Haskell
|
||||||
|
uses: haskell/actions/setup@v1
|
||||||
|
id: setup-haskell
|
||||||
|
with:
|
||||||
|
ghc-version: ${{ matrix.ghc }}
|
||||||
|
cabal-version: 3.8.1.0
|
||||||
|
|
||||||
|
- name: Select build directory
|
||||||
|
run: |
|
||||||
|
if [ "$RUNNER_OS" == Windows ]; then
|
||||||
|
CABAL_BUILDDIR="D:\\a\\_temp\\dist"
|
||||||
|
else
|
||||||
|
CABAL_BUILDDIR="dist-newstyle"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "CABAL_BUILDDIR=$CABAL_BUILDDIR"
|
||||||
|
echo "CABAL_BUILDDIR=$CABAL_BUILDDIR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set cache version
|
||||||
|
run: echo "CACHE_VERSION=9w76Z3Q" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set up temp directory
|
||||||
|
env:
|
||||||
|
RUNNER_TEMP: ${{ runner.temp }}
|
||||||
|
run: |
|
||||||
|
echo "TMPDIR=$RUNNER_TEMP" >> $GITHUB_ENV
|
||||||
|
echo "TMP=$RUNNER_TEMP" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Record dependencies
|
||||||
|
id: record-deps
|
||||||
|
run: |
|
||||||
|
cabal build all --dry-run
|
||||||
|
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
|
||||||
|
|
||||||
|
- name: Cache `cabal store`
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ steps.setup-haskell.outputs.cabal-store }}
|
||||||
|
key: cabal-store-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
|
||||||
|
restore-keys: cabal-store-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
|
||||||
|
|
||||||
|
- name: Cache `dist-newstyle`
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
dist-newstyle
|
||||||
|
!dist-newstyle/**/.git
|
||||||
|
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
|
||||||
|
|
||||||
|
- name: Use cabal.project.local
|
||||||
|
run: |
|
||||||
|
cat .github/workflows/cabal.project.local >> ./cabal.project.local
|
||||||
|
cat ./cabal.project.local
|
||||||
|
|
||||||
|
- name: Build dependencies
|
||||||
|
run: cabal --builddir="$CABAL_BUILDDIR" build --only-dependencies all
|
||||||
|
|
||||||
|
- name: Build projects [build]
|
||||||
|
run: cabal --builddir="$CABAL_BUILDDIR" build all
|
||||||
|
|
||||||
|
- name: free-category [test]
|
||||||
|
run: cabal --builddir="$CABAL_BUILDDIR" run free-category:test-cats
|
||||||
|
|
||||||
|
- name: free-category [benchmarks]
|
||||||
|
run: cabal build free-category:benchmarks
|
||||||
|
|
32
.github/workflows/posix.yml
vendored
32
.github/workflows/posix.yml
vendored
@ -1,32 +0,0 @@
|
|||||||
name: "Haskell/CI"
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
name: "free-category"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: cachix/install-nix-action@v12
|
|
||||||
with:
|
|
||||||
extra_nix_config: |
|
|
||||||
substituters = https://cache.nixos.org https://hydra.iohk.io
|
|
||||||
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
|
|
||||||
- name: "cachix"
|
|
||||||
uses: cachix/cachix-action@v8
|
|
||||||
with:
|
|
||||||
name: "free-algebras"
|
|
||||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
|
||||||
|
|
||||||
- name: "cachix iohk"
|
|
||||||
run: cachix use iohk
|
|
||||||
|
|
||||||
- name: "[GHC 8.6.5] free-category"
|
|
||||||
run: |
|
|
||||||
nix-build default.nix --argstr compiler ghc865 -A free-category
|
|
||||||
|
|
||||||
- name: "[GHC 8.8.4] free-category"
|
|
||||||
run: nix-build default.nix --argstr compiler ghc884 -A free-category
|
|
||||||
|
|
||||||
- name: "[GHC 8.10.4] free-category"
|
|
||||||
run: nix-build default.nix --argstr compiler ghc8104 -A free-category
|
|
@ -1,3 +1,4 @@
|
|||||||
index-state: 2021-03-15T00:00:00Z
|
index-state: 2022-09-06T18:00:00Z
|
||||||
packages: free-category.cabal
|
|
||||||
examples/examples.cabal
|
packages: .
|
||||||
|
examples
|
||||||
|
41
default.nix
41
default.nix
@ -1,41 +0,0 @@
|
|||||||
{ compiler ? "ghc8104"
|
|
||||||
}:
|
|
||||||
let compiler-nix-name = compiler;
|
|
||||||
|
|
||||||
sources = import ./nix/sources.nix {};
|
|
||||||
iohkNix = import sources.iohk-nix {};
|
|
||||||
haskellNix = import sources."haskell.nix" {};
|
|
||||||
nixpkgs = iohkNix.nixpkgs;
|
|
||||||
haskell-nix = haskellNix.pkgs.haskell-nix;
|
|
||||||
|
|
||||||
# package set
|
|
||||||
pkgs = import nixpkgs
|
|
||||||
{ config = haskellNix.config;
|
|
||||||
overlays = [ (_: _: { inherit freeCategoryPackages; }) ];
|
|
||||||
};
|
|
||||||
lib = pkgs.lib;
|
|
||||||
|
|
||||||
# 'cleanGit' cleans a source directory based on the files known by git
|
|
||||||
src = haskell-nix.haskellLib.cleanGit {
|
|
||||||
name = "free-category";
|
|
||||||
src = ./.;
|
|
||||||
};
|
|
||||||
|
|
||||||
# unmodified packages
|
|
||||||
projectPackages = lib.attrNames
|
|
||||||
(haskell-nix.haskellLib.selectProjectPackages
|
|
||||||
(haskell-nix.cabalProject { inherit src compiler-nix-name; }));
|
|
||||||
|
|
||||||
# set GHC options
|
|
||||||
freeCategoryPackages = haskell-nix.cabalProject {
|
|
||||||
inherit src compiler-nix-name;
|
|
||||||
modules =
|
|
||||||
[
|
|
||||||
{ packages =
|
|
||||||
lib.genAttrs
|
|
||||||
projectPackages
|
|
||||||
(name: { configureFlags = [ "--ghc-option=-Werror" ]; });
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in pkgs.freeCategoryPackages
|
|
@ -23,7 +23,7 @@ extra-source-files:
|
|||||||
bench/report-O1.md
|
bench/report-O1.md
|
||||||
bench/report-O2.md
|
bench/report-O2.md
|
||||||
stability: experimental
|
stability: experimental
|
||||||
tested-with: GHC==8.6.5, GHC==8.8.4, GHC==8.10.4
|
tested-with: GHC==8.8.4, GHC==8.10.7, GHC==9.0.2, GHC==9.2.4, GHC==9.4.2
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"haskell.nix": {
|
|
||||||
"branch": "master",
|
|
||||||
"description": "Alternative Haskell Infrastructure for Nixpkgs",
|
|
||||||
"homepage": "https://input-output-hk.github.io/haskell.nix",
|
|
||||||
"owner": "input-output-hk",
|
|
||||||
"repo": "haskell.nix",
|
|
||||||
"rev": "6c9facfada85bd298691ecb2b5b2d124c342f869",
|
|
||||||
"sha256": "07w6wq6rsiq4j26vmi0mvh68wajjj8bd4qjbny2gkdf9jnnf9jj8",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://github.com/input-output-hk/haskell.nix/archive/6c9facfada85bd298691ecb2b5b2d124c342f869.tar.gz",
|
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
|
||||||
},
|
|
||||||
"iohk-nix": {
|
|
||||||
"branch": "master",
|
|
||||||
"description": "nix scripts shared across projects",
|
|
||||||
"homepage": null,
|
|
||||||
"owner": "input-output-hk",
|
|
||||||
"repo": "iohk-nix",
|
|
||||||
"rev": "bc4216c5b0e14dbde5541763f4952f99c3c712fa",
|
|
||||||
"sha256": "0y5n3limj5dg1vgxyxafg0ky35qq7w97rr00gr3yl16xx5jrhs6w",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://github.com/input-output-hk/iohk-nix/archive/bc4216c5b0e14dbde5541763f4952f99c3c712fa.tar.gz",
|
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
|
||||||
},
|
|
||||||
"niv": {
|
|
||||||
"branch": "master",
|
|
||||||
"description": "Easy dependency management for Nix projects",
|
|
||||||
"homepage": "https://github.com/nmattia/niv",
|
|
||||||
"owner": "nmattia",
|
|
||||||
"repo": "niv",
|
|
||||||
"rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e",
|
|
||||||
"sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz",
|
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
|
||||||
}
|
|
||||||
}
|
|
171
nix/sources.nix
171
nix/sources.nix
@ -1,171 +0,0 @@
|
|||||||
# This file has been generated by Niv.
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
#
|
|
||||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
|
||||||
#
|
|
||||||
|
|
||||||
fetch_file = pkgs: name: spec:
|
|
||||||
let
|
|
||||||
name' = sanitizeName name + "-src";
|
|
||||||
in
|
|
||||||
if spec.builtin or true then
|
|
||||||
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
|
||||||
else
|
|
||||||
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
|
||||||
|
|
||||||
fetch_tarball = pkgs: name: spec:
|
|
||||||
let
|
|
||||||
name' = sanitizeName name + "-src";
|
|
||||||
in
|
|
||||||
if spec.builtin or true then
|
|
||||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
|
||||||
else
|
|
||||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
|
||||||
|
|
||||||
fetch_git = name: spec:
|
|
||||||
let
|
|
||||||
ref =
|
|
||||||
if spec ? ref then spec.ref else
|
|
||||||
if spec ? branch then "refs/heads/${spec.branch}" else
|
|
||||||
if spec ? tag then "refs/tags/${spec.tag}" else
|
|
||||||
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
|
||||||
in
|
|
||||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
|
||||||
|
|
||||||
fetch_local = spec: spec.path;
|
|
||||||
|
|
||||||
fetch_builtin-tarball = name: throw
|
|
||||||
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
|
||||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
|
||||||
|
|
||||||
fetch_builtin-url = name: throw
|
|
||||||
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
|
||||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
|
||||||
|
|
||||||
#
|
|
||||||
# Various helpers
|
|
||||||
#
|
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
|
||||||
sanitizeName = name:
|
|
||||||
(
|
|
||||||
concatMapStrings (s: if builtins.isList s then "-" else s)
|
|
||||||
(
|
|
||||||
builtins.split "[^[:alnum:]+._?=-]+"
|
|
||||||
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
# The set of packages used when specs are fetched using non-builtins.
|
|
||||||
mkPkgs = sources: system:
|
|
||||||
let
|
|
||||||
sourcesNixpkgs =
|
|
||||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
|
||||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
|
||||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
|
||||||
in
|
|
||||||
if builtins.hasAttr "nixpkgs" sources
|
|
||||||
then sourcesNixpkgs
|
|
||||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
|
||||||
import <nixpkgs> {}
|
|
||||||
else
|
|
||||||
abort
|
|
||||||
''
|
|
||||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
|
||||||
add a package called "nixpkgs" to your sources.json.
|
|
||||||
'';
|
|
||||||
|
|
||||||
# The actual fetching function.
|
|
||||||
fetch = pkgs: name: spec:
|
|
||||||
|
|
||||||
if ! builtins.hasAttr "type" spec then
|
|
||||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
|
||||||
else if spec.type == "file" then fetch_file pkgs name spec
|
|
||||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
|
||||||
else if spec.type == "git" then fetch_git name spec
|
|
||||||
else if spec.type == "local" then fetch_local spec
|
|
||||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
|
||||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
|
||||||
else
|
|
||||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
|
||||||
|
|
||||||
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
|
||||||
# the path directly as opposed to the fetched source.
|
|
||||||
replace = name: drv:
|
|
||||||
let
|
|
||||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
|
||||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
|
||||||
in
|
|
||||||
if ersatz == "" then drv else ersatz;
|
|
||||||
|
|
||||||
# Ports of functions for older nix versions
|
|
||||||
|
|
||||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
|
||||||
mapAttrs = builtins.mapAttrs or (
|
|
||||||
f: set: with builtins;
|
|
||||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
|
||||||
);
|
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
|
||||||
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
|
||||||
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
|
||||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
|
||||||
concatMapStrings = f: list: concatStrings (map f list);
|
|
||||||
concatStrings = builtins.concatStringsSep "";
|
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
|
||||||
optionalAttrs = cond: as: if cond then as else {};
|
|
||||||
|
|
||||||
# fetchTarball version that is compatible between all the versions of Nix
|
|
||||||
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
|
||||||
let
|
|
||||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
|
||||||
in
|
|
||||||
if lessThan nixVersion "1.12" then
|
|
||||||
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
|
||||||
else
|
|
||||||
fetchTarball attrs;
|
|
||||||
|
|
||||||
# fetchurl version that is compatible between all the versions of Nix
|
|
||||||
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
|
||||||
let
|
|
||||||
inherit (builtins) lessThan nixVersion fetchurl;
|
|
||||||
in
|
|
||||||
if lessThan nixVersion "1.12" then
|
|
||||||
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
|
||||||
else
|
|
||||||
fetchurl attrs;
|
|
||||||
|
|
||||||
# Create the final "sources" from the config
|
|
||||||
mkSources = config:
|
|
||||||
mapAttrs (
|
|
||||||
name: spec:
|
|
||||||
if builtins.hasAttr "outPath" spec
|
|
||||||
then abort
|
|
||||||
"The values in sources.json should not have an 'outPath' attribute"
|
|
||||||
else
|
|
||||||
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
|
||||||
) config.sources;
|
|
||||||
|
|
||||||
# The "config" used by the fetchers
|
|
||||||
mkConfig =
|
|
||||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
|
||||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
|
||||||
, system ? builtins.currentSystem
|
|
||||||
, pkgs ? mkPkgs sources system
|
|
||||||
}: rec {
|
|
||||||
# The sources, i.e. the attribute set of spec name to spec
|
|
||||||
inherit sources;
|
|
||||||
|
|
||||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
|
||||||
inherit pkgs;
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
|
@ -37,10 +37,6 @@ module Control.Arrow.Free
|
|||||||
import Prelude hiding (id, (.))
|
import Prelude hiding (id, (.))
|
||||||
import Control.Arrow (Arrow (..), ArrowChoice (..), (>>>))
|
import Control.Arrow (Arrow (..), ArrowChoice (..), (>>>))
|
||||||
import Control.Category (Category (..))
|
import Control.Category (Category (..))
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
import Data.Monoid (Monoid (..))
|
|
||||||
import Data.Semigroup (Semigroup (..))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Control.Algebra.Free2
|
import Control.Algebra.Free2
|
||||||
( AlgebraType0
|
( AlgebraType0
|
||||||
@ -97,9 +93,6 @@ instance Semigroup (Arr f o o) where
|
|||||||
|
|
||||||
instance Monoid (Arr f o o) where
|
instance Monoid (Arr f o o) where
|
||||||
mempty = Id
|
mempty = Id
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
mappend = (<>)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance Arrow (Arr f) where
|
instance Arrow (Arr f) where
|
||||||
arr = arrArr
|
arr = arrArr
|
||||||
@ -155,9 +148,6 @@ instance Semigroup (A f o o) where
|
|||||||
|
|
||||||
instance Monoid (A f o o) where
|
instance Monoid (A f o o) where
|
||||||
mempty = id
|
mempty = id
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
mappend = (<>)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance Arrow (A f) where
|
instance Arrow (A f) where
|
||||||
arr f = A (\_ -> (arr f))
|
arr f = A (\_ -> (arr f))
|
||||||
|
@ -11,20 +11,10 @@
|
|||||||
{-# LANGUAGE TypeOperators #-}
|
{-# LANGUAGE TypeOperators #-}
|
||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
{-# LANGUAGE ViewPatterns #-}
|
{-# LANGUAGE ViewPatterns #-}
|
||||||
#if __GLASGOW_HASKELL__ >= 806
|
|
||||||
{-# LANGUAGE QuantifiedConstraints #-}
|
{-# LANGUAGE QuantifiedConstraints #-}
|
||||||
#endif
|
|
||||||
|
|
||||||
{-# OPTIONS_HADDOCK show-extensions #-}
|
{-# OPTIONS_HADDOCK show-extensions #-}
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ <= 802
|
|
||||||
-- ghc802 does not infer that 'cons' is used when using a bidirectional
|
|
||||||
-- pattern
|
|
||||||
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
|
|
||||||
-- the 'complete' pragma was introduced in ghc804
|
|
||||||
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
module Control.Category.Free
|
module Control.Category.Free
|
||||||
( -- * Real time Queue
|
( -- * Real time Queue
|
||||||
Queue (ConsQ, NilQ)
|
Queue (ConsQ, NilQ)
|
||||||
@ -83,10 +73,6 @@ import Control.Algebra.Free2
|
|||||||
, bindFree2
|
, bindFree2
|
||||||
)
|
)
|
||||||
import Control.Arrow (Arrow (..), ArrowZero (..), ArrowChoice (..))
|
import Control.Arrow (Arrow (..), ArrowZero (..), ArrowChoice (..))
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
import Data.Monoid (Monoid (..))
|
|
||||||
import Data.Semigroup (Semigroup (..))
|
|
||||||
#endif
|
|
||||||
import Data.Kind (Type)
|
import Data.Kind (Type)
|
||||||
|
|
||||||
import Control.Category.Free.Internal
|
import Control.Category.Free.Internal
|
||||||
@ -169,17 +155,10 @@ instance Category (C f) where
|
|||||||
id = C (\_ -> id)
|
id = C (\_ -> id)
|
||||||
(.) = composeC
|
(.) = composeC
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ >= 806
|
|
||||||
-- | Show instance via 'ListTr'
|
-- | Show instance via 'ListTr'
|
||||||
--
|
--
|
||||||
instance (forall x y. Show (f x y)) => Show (C f a b) where
|
instance (forall x y. Show (f x y)) => Show (C f a b) where
|
||||||
show c = show (hoistFreeH2 c :: ListTr f a b)
|
show c = show (hoistFreeH2 c :: ListTr f a b)
|
||||||
#else
|
|
||||||
-- | Blind show instance via 'ListTr'
|
|
||||||
--
|
|
||||||
instance Show (C f a b) where
|
|
||||||
show c = show (hoistFreeH2 c :: ListTr f a b)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
type instance AlgebraType0 C f = ()
|
type instance AlgebraType0 C f = ()
|
||||||
type instance AlgebraType C c = Category c
|
type instance AlgebraType C c = Category c
|
||||||
@ -212,6 +191,3 @@ instance Semigroup (C f o o) where
|
|||||||
|
|
||||||
instance Monoid (C f o o) where
|
instance Monoid (C f o o) where
|
||||||
mempty = id
|
mempty = id
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
mappend = (<>)
|
|
||||||
#endif
|
|
||||||
|
@ -6,23 +6,12 @@
|
|||||||
{-# LANGUAGE RankNTypes #-}
|
{-# LANGUAGE RankNTypes #-}
|
||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
{-# LANGUAGE TypeOperators #-}
|
||||||
{-# LANGUAGE ViewPatterns #-}
|
{-# LANGUAGE ViewPatterns #-}
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ >= 806
|
|
||||||
{-# LANGUAGE QuantifiedConstraints #-}
|
{-# LANGUAGE QuantifiedConstraints #-}
|
||||||
#endif
|
|
||||||
|
|
||||||
{-# OPTIONS_HADDOCK show-extensions #-}
|
{-# OPTIONS_HADDOCK show-extensions #-}
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ <= 802
|
|
||||||
-- ghc802 does not infer that 'consQ' is used when using a bidirectional
|
|
||||||
-- pattern
|
|
||||||
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
|
|
||||||
-- the 'complete' pragma was introduced in ghc804
|
|
||||||
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
-- | Internal module, contains implementation of type aligned real time queues
|
-- | Internal module, contains implementation of type aligned real time queues
|
||||||
-- (C.Okasaki 'Purely Functional Data Structures').
|
-- (C.Okasaki 'Purely Functional Data Structures').
|
||||||
--
|
--
|
||||||
@ -56,10 +45,6 @@ module Control.Category.Free.Internal
|
|||||||
import Prelude hiding (id, (.))
|
import Prelude hiding (id, (.))
|
||||||
import Control.Arrow
|
import Control.Arrow
|
||||||
import Control.Category (Category (..))
|
import Control.Category (Category (..))
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
import Data.Monoid (Monoid (..))
|
|
||||||
import Data.Semigroup (Semigroup (..))
|
|
||||||
#endif
|
|
||||||
import Data.Kind (Type)
|
import Data.Kind (Type)
|
||||||
|
|
||||||
import Control.Algebra.Free2 ( AlgebraType0
|
import Control.Algebra.Free2 ( AlgebraType0
|
||||||
@ -95,9 +80,6 @@ instance Category f => Semigroup (Op f o o) where
|
|||||||
|
|
||||||
instance Category f => Monoid (Op f o o) where
|
instance Category f => Monoid (Op f o o) where
|
||||||
mempty = id
|
mempty = id
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
mappend = (<>)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -208,15 +190,9 @@ zipWithL fn queueA queueB = case (queueA, queueB) of
|
|||||||
(ConsTr trA' queueA', ConsTr trB' queueB')
|
(ConsTr trA' queueA', ConsTr trB' queueB')
|
||||||
-> ConsTr (trA' `fn` trB') (zipWithL fn queueA' queueB')
|
-> ConsTr (trA' `fn` trB') (zipWithL fn queueA' queueB')
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ >= 806
|
|
||||||
instance (forall (x :: k) (y :: k). Show (f x y)) => Show (ListTr f a b) where
|
instance (forall (x :: k) (y :: k). Show (f x y)) => Show (ListTr f a b) where
|
||||||
show NilTr = "NilTr"
|
show NilTr = "NilTr"
|
||||||
show (ConsTr x xs) = "ConsTr " ++ show x ++ " " ++ show xs
|
show (ConsTr x xs) = "ConsTr " ++ show x ++ " " ++ show xs
|
||||||
#else
|
|
||||||
instance Show (ListTr f a b) where
|
|
||||||
show NilTr = "NilTr"
|
|
||||||
show (ConsTr _ xs) = "ConsTr _ " ++ show xs
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance Category (ListTr f) where
|
instance Category (ListTr f) where
|
||||||
id = NilTr
|
id = NilTr
|
||||||
@ -239,9 +215,6 @@ instance Semigroup (ListTr f o o) where
|
|||||||
|
|
||||||
instance Monoid (ListTr f o o) where
|
instance Monoid (ListTr f o o) where
|
||||||
mempty = NilTr
|
mempty = NilTr
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
mappend = (<>)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance Arrow f => Arrow (ListTr f) where
|
instance Arrow f => Arrow (ListTr f) where
|
||||||
arr ab = arr ab `ConsTr` NilTr
|
arr ab = arr ab `ConsTr` NilTr
|
||||||
@ -292,9 +265,7 @@ pattern NilQ :: () => a ~ b => Queue f a b
|
|||||||
pattern NilQ <- (unconsQ -> EmptyL) where
|
pattern NilQ <- (unconsQ -> EmptyL) where
|
||||||
NilQ = nilQ
|
NilQ = nilQ
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ > 802
|
|
||||||
{-# complete NilQ, ConsQ #-}
|
{-# complete NilQ, ConsQ #-}
|
||||||
#endif
|
|
||||||
|
|
||||||
composeQ :: forall k (f :: k -> k -> Type) x y z.
|
composeQ :: forall k (f :: k -> k -> Type) x y z.
|
||||||
Queue f y z
|
Queue f y z
|
||||||
@ -463,7 +434,6 @@ hoistQ nat q = case q of
|
|||||||
|
|
||||||
#-}
|
#-}
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ >= 806
|
|
||||||
instance (forall (x :: k) (y :: k). Show (f x y))
|
instance (forall (x :: k) (y :: k). Show (f x y))
|
||||||
=> Show (Queue f a b) where
|
=> Show (Queue f a b) where
|
||||||
show (Queue f r s) =
|
show (Queue f r s) =
|
||||||
@ -473,16 +443,6 @@ instance (forall (x :: k) (y :: k). Show (f x y))
|
|||||||
++ show r
|
++ show r
|
||||||
++ ") "
|
++ ") "
|
||||||
++ show (lengthListTr s)
|
++ show (lengthListTr s)
|
||||||
#else
|
|
||||||
instance Show (Queue f r s) where
|
|
||||||
show (Queue f r s) =
|
|
||||||
"Queue "
|
|
||||||
++ show (lengthListTr f)
|
|
||||||
++ " "
|
|
||||||
++ show (lengthListTr r)
|
|
||||||
++ " "
|
|
||||||
++ show (lengthListTr s)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance Category (Queue f) where
|
instance Category (Queue f) where
|
||||||
id = NilQ
|
id = NilQ
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE DataKinds #-}
|
{-# LANGUAGE DataKinds #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
|
#if __GLASGOW_HASKELL__ >= 902
|
||||||
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
|
#endif
|
||||||
{-# LANGUAGE GADTs #-}
|
{-# LANGUAGE GADTs #-}
|
||||||
{-# LANGUAGE KindSignatures #-}
|
{-# LANGUAGE KindSignatures #-}
|
||||||
{-# LANGUAGE PolyKinds #-}
|
{-# LANGUAGE PolyKinds #-}
|
||||||
@ -8,9 +11,7 @@
|
|||||||
{-# LANGUAGE TypeApplications #-}
|
{-# LANGUAGE TypeApplications #-}
|
||||||
{-# LANGUAGE TupleSections #-}
|
{-# LANGUAGE TupleSections #-}
|
||||||
{-# LANGUAGE UndecidableInstances #-}
|
{-# LANGUAGE UndecidableInstances #-}
|
||||||
#if __GLASGOW_HASKELL__ >= 806
|
|
||||||
{-# LANGUAGE QuantifiedConstraints #-}
|
{-# LANGUAGE QuantifiedConstraints #-}
|
||||||
#endif
|
|
||||||
|
|
||||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||||
|
|
||||||
@ -19,10 +20,6 @@ module Test.Cat (tests) where
|
|||||||
import Prelude hiding ((.), id)
|
import Prelude hiding ((.), id)
|
||||||
import Control.Category
|
import Control.Category
|
||||||
import Data.Function (on)
|
import Data.Function (on)
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
import Data.Monoid (Monoid (..))
|
|
||||||
import Data.Semigroup (Semigroup (..))
|
|
||||||
#endif
|
|
||||||
import Text.Show.Functions ()
|
import Text.Show.Functions ()
|
||||||
import Numeric.Natural (Natural)
|
import Numeric.Natural (Natural)
|
||||||
|
|
||||||
@ -173,7 +170,6 @@ genNextTr b = do
|
|||||||
data ArbListTr where
|
data ArbListTr where
|
||||||
ArbListTr :: Eq b => ListTr Tr a b -> Sing a -> Sing b -> ArbListTr
|
ArbListTr :: Eq b => ListTr Tr a b -> Sing a -> Sing b -> ArbListTr
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ >= 806
|
|
||||||
instance (forall x y. Show (Tr x y)) => Show ArbListTr where
|
instance (forall x y. Show (Tr x y)) => Show ArbListTr where
|
||||||
show (ArbListTr listTr a b) =
|
show (ArbListTr listTr a b) =
|
||||||
"ArbListTr "
|
"ArbListTr "
|
||||||
@ -182,14 +178,6 @@ instance (forall x y. Show (Tr x y)) => Show ArbListTr where
|
|||||||
++ show b
|
++ show b
|
||||||
++ " "
|
++ " "
|
||||||
++ show listTr
|
++ show listTr
|
||||||
#else
|
|
||||||
instance Show ArbListTr where
|
|
||||||
show (ArbListTr _listTr a b) =
|
|
||||||
"ArbListTr "
|
|
||||||
++ show a
|
|
||||||
++ " -> "
|
|
||||||
++ show b
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance Arbitrary ArbListTr where
|
instance Arbitrary ArbListTr where
|
||||||
arbitrary = sized $ \n -> do
|
arbitrary = sized $ \n -> do
|
||||||
@ -281,9 +269,6 @@ instance Semigroup (IntCat '() '()) where
|
|||||||
|
|
||||||
instance Monoid (IntCat '() '()) where
|
instance Monoid (IntCat '() '()) where
|
||||||
mempty = IntCat 0
|
mempty = IntCat 0
|
||||||
#if __GLASGOW_HASKELL__ < 804
|
|
||||||
mappend = (<>)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance Arbitrary (IntCat '() '()) where
|
instance Arbitrary (IntCat '() '()) where
|
||||||
arbitrary = IntCat <$> arbitrary
|
arbitrary = IntCat <$> arbitrary
|
||||||
|
Loading…
Reference in New Issue
Block a user