git.iko.soy/typeable/cassava-streams
on trunk help sign in
18 files changed+362−124
since splitsnapshots
unifiedsplit
.envrc+10 .github/workflows/analysis.yml+22 .github/workflows/tests.yml+63 .gitignore+3−5 CHANGES.md+19 GNUmakefile−28 LICENSE+1−1 README.md+4 build/nixpkgs.nix−13 build/stack.yaml−9 cassava-streams.cabal+49−65 data/HLint.hs+3 default.nix+11 nix/sources.json+38 nix/sources.nix+134 shell.nix+2 src/System/IO/Streams/Csv/Decode.hs+2−2 test/test.hs+1−1
.envrcnew file+10
@@ -0,0 +1,10 @@
1+# -*- sh -*-
2+
3+# Don't let cabal leak state to other projects:
4+export CABAL_DIR=$(pwd)/.cabal
5+
6+# Load in the shell.nix file:
7+use nix
8+
9+# Reload if these files change:
10+watch_file nix/sources.json
.github/workflows/analysis.ymlnew file+22
@@ -0,0 +1,22 @@
1+name: Analysis
2+on:
3+ pull_request:
4+jobs:
5+ check:
6+ name: pre-merge-checks
7+ runs-on: ubuntu-latest
8+ steps:
9+ - name: Clone Repository
10+ uses: actions/checkout@v2
11+
12+ - name: Setup Haskell
13+ id: setup-haskell-cabal
14+ uses: actions/setup-haskell@v1.1.3
15+ with:
16+ ghc-version: 8.8
17+
18+ - name: Cabal Check
19+ run: cabal check
20+
21+ - name: Lint
22+ run: curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
.github/workflows/tests.ymlnew file+63
@@ -0,0 +1,63 @@
1+name: CI
2+on:
3+ pull_request:
4+jobs:
5+ cabal:
6+ name: ${{ matrix.os }} / ghc-${{ matrix.ghc }}
7+ runs-on: ${{ matrix.os }}
8+ strategy:
9+ fail-fast: false
10+ matrix:
11+ os: [ubuntu-latest, macOS-latest, windows-latest]
12+ cabal: ["3.2"]
13+ ghc: ["8.6.5", "8.8.4", "8.10.2"]
14+ # Newer versions of GHC are broken on Windows:
15+ # https://gitlab.haskell.org/ghc/ghc/-/issues/17926
16+ exclude:
17+ - os: windows-latest
18+ ghc: "8.8.4"
19+ - os: windows-latest
20+ ghc: "8.10.2"
21+ steps:
22+ - name: Clone Repository
23+ uses: actions/checkout@v2
24+
25+ - name: Setup Haskell
26+ id: setup-haskell-cabal
27+ uses: actions/setup-haskell@v1.1.3
28+ with:
29+ ghc-version: ${{ matrix.ghc }}
30+ cabal-version: ${{ matrix.cabal }}
31+
32+ - name: Configure and Freeze for Cache
33+ run: |
34+ cabal configure --enable-tests --enable-benchmarks --test-show-details=direct -ftutorial
35+ cabal freeze
36+
37+ - name: Cache ~/.cabal/store
38+ uses: actions/cache@v1
39+ with:
40+ path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
41+ key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
42+
43+ - name: Build
44+ run: cabal build '--build-log=logs/$pkgid'
45+
46+ - name: Test
47+ run: cabal test
48+
49+ - name: Upload Build Logs on Failure
50+ uses: actions/upload-artifact@v2
51+ if: failure()
52+ with:
53+ name: logs-${{ matrix.os }}-ghc${{ matrix.ghc }}
54+ path: logs/
55+
56+ - name: Install
57+ run: cabal install --installdir=artifacts --install-method=copy
58+
59+ - name: Upload Artifacts
60+ uses: actions/upload-artifact@v2
61+ with:
62+ name: ${{ matrix.os }}-ghc${{ matrix.ghc }}
63+ path: artifacts/
.gitignore+3−5
@@ -1,8 +1,6 @@
1−/dist
2−/.cabal-sandbox
3−/cabal.sandbox.config
41/test/massive.csv
52/.stack-work
63/build/.stack-work
7−/default.nix
8−/stack.yaml
4+/dist
5+/result
6+/.cabal/
CHANGES.md+19
@@ -1,9 +1,28 @@
11# Change Log / Release Notes
22
3+## 0.3 (August 11, 2016)
4+
5+ * Add some additional (convenience) exports from `Data.Csv`. (Thanks
6+ goes to Florian Hofmann.)
7+
8+ * Added `data/HLint.hs`
9+
10+ * Updated to LTS Haskell 6.7
11+
12+ * Minor updates:
13+
14+ - 0.3.0.1 (April 14, 2017): Updated dependencies
15+ - 0.3.0.2 (March 20, 2018): Updated dependencies
16+ - 0.3.0.3 (October 09, 2018): Updated dependencies
17+ - 0.3.0.4 (April 15, 2019): Updated dependencies
18+ - 0.3.0.5 (October 29, 2020): Update dependencies
19+
320## 0.2.0.0 (February 8, 2016)
421
522 * Compile with GHC 7.10.3
23+
624 * Update dependency versions
25+
726 * Build with stack and LTS Haskell 5.2
827
928## 0.1.1.0 (November 11, 2014)
GNUmakefiledeleted−28
@@ -1,28 +0,0 @@
1−################################################################################
2−export TMPDIR = $(HOME)/tmp
3−
4−################################################################################
5−TMP_DUMMY = $(TMPDIR)/.dummy
6−STACK_OPTS = --stack-yaml=build/stack.yaml
7−
8−################################################################################
9−.PHONY: all test clean release
10−
11−################################################################################
12−all: $(TMP_DUMMY)
13− stack $(STACK_OPTS) setup
14− stack $(STACK_OPTS) build
15− hlint src test
16−
17−################################################################################
18−test:
19− stack $(STACK_OPTS) test
20−
21−################################################################################
22−clean:
23− stack $(STACK_OPTS) clean
24−
25−################################################################################
26−release:
27− $(MAKE) clean test
28− stack $(STACK_OPTS) upload .
LICENSE+1−1
@@ -1,4 +1,4 @@
1−Copyright (c) 2014-2016 Peter Jones <pjones@devalot.com>
1+Copyright (c) 2014-2020 Peter Jones <pjones@devalot.com>
22
33All rights reserved.
44
README.md+4
@@ -1,5 +1,9 @@
11# cassava-streams
22
3+[![CI](https://github.com/pjones/cassava-streams/workflows/CI/badge.svg)](https://github.com/pjones/cassava-streams/actions)
4+[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/pjones/cassava-streams?label=release)](https://github.com/pjones/cassava-streams/releases)
5+[![Hackage](https://img.shields.io/hackage/v/cassava-streams)](https://hackage.haskell.org/package/cassava-streams)
6+
37[io-streams][] interface for the [cassava][] CSV library.
48
59[io-streams]: http://hackage.haskell.org/package/io-streams
build/nixpkgs.nixdeleted−13
@@ -1,13 +0,0 @@
1−with (import <nixpkgs> {});
2−
3−stdenv.mkDerivation {
4− name = "cassava-streams";
5−
6− buildInputs = [
7− # GHC:
8− haskell.packages.lts-4_2.ghc
9−
10− # Non-Haskell Dependencies:
11− zlib
12− ];
13−}
build/stack.yamldeleted−9
@@ -1,9 +0,0 @@
1−resolver: lts-5.2
2−
3−packages:
4− - ../
5−
6−flags:
7− cassava-streams:
8− maintainer: true
9− tutorial: true
cassava-streams.cabal+49−65
@@ -1,18 +1,17 @@
1−--------------------------------------------------------------------------------
2−name: cassava-streams
3−version: 0.2.0.0
4−synopsis: io-streams interface for the cassava CSV library.
5−license: BSD3
6−license-file: LICENSE
7−author: Peter Jones <pjones@devalot.com>
8−maintainer: Peter Jones <pjones@devalot.com>
9−copyright: Copyright (c) 2014-2016 Peter Jones
10−category: Data, Text, CSV, IO-Streams
11−build-type: Simple
12−cabal-version: >=1.18
13−tested-with: GHC==7.10.3
14−homepage: https://github.com/pjones/cassava-streams
15−bug-reports: https://github.com/pjones/cassava-streams/issues
1+cabal-version: 2.2
2+name: cassava-streams
3+version: 0.3.0.5
4+synopsis: io-streams interface for the cassava CSV library.
5+license: BSD-3-Clause
6+license-file: LICENSE
7+author: Peter Jones <pjones@devalot.com>
8+maintainer: Peter Jones <pjones@devalot.com>
9+copyright: Copyright (c) 2014-2020 Peter Jones
10+category: Data, Text, CSV, IO-Streams
11+build-type: Simple
12+homepage: https://github.com/pjones/cassava-streams
13+bug-reports: https://github.com/pjones/cassava-streams/issues
14+tested-with: GHC ==8.6.5 || ==8.8.4 || ==8.10.2
1615description:
1716 The cassava-streams library glues togeter the cassava CSV library
1817 and the io-streams streaming library.
@@ -24,84 +23,69 @@ extra-source-files:
2423 README.md
2524 CHANGES.md
2625 test/*.csv
27− build/*.yaml
28− build/*.nix
2926
3027--------------------------------------------------------------------------------
3128source-repository head
3229 type: git
3330 location: https://github.com/pjones/cassava-streams.git
3431
35−--------------------------------------------------------------------------------
36−flag maintainer
37− description: Enable settings for the package maintainer.
38− manual: True
39− default: False
40−
4132--------------------------------------------------------------------------------
4233flag tutorial
4334 description: Build the tutorial binary (useful for profiling).
44− manual: True
45− default: False
35+ manual: True
36+ default: False
37+
38+--------------------------------------------------------------------------------
39+common dependencies
40+ build-depends:
41+ , base >=4.8 && <5.0
42+ , bytestring >=0.10 && <0.12
43+ , cassava >=0.4 && <0.6
44+ , io-streams >=1.1 && <1.6
45+ , vector >=0.10 && <0.14
4646
4747--------------------------------------------------------------------------------
4848library
49+ import: dependencies
4950 exposed-modules:
5051 System.IO.Streams.Csv
5152 System.IO.Streams.Csv.Tutorial
53+
5254 other-modules:
53− System.IO.Streams.Csv.Encode
5455 System.IO.Streams.Csv.Decode
56+ System.IO.Streams.Csv.Encode
5557
56− hs-source-dirs: src
58+ hs-source-dirs: src
5759 default-language: Haskell2010
58− ghc-options: -Wall -fwarn-incomplete-uni-patterns
59−
60− if flag(maintainer)
61− ghc-options: -Werror
62− ghc-prof-options: -prof -auto-all
63−
64− build-depends: base >= 4.6 && < 5.0
65− , bytestring >= 0.10 && < 0.11
66− , cassava >= 0.4 && < 0.5
67− , io-streams >= 1.1 && < 1.4
68− , vector >= 0.10 && < 0.12
60+ ghc-options: -Wall -fwarn-incomplete-uni-patterns
61+ build-depends:
6962
7063--------------------------------------------------------------------------------
7164executable tutorial
7265 default-language: Haskell2010
73− hs-source-dirs: bin
74− main-is: tutorial.hs
75− ghc-options: -Wall -fwarn-incomplete-uni-patterns -rtsopts
76−
77− if flag(maintainer)
78− ghc-options: -Werror
79− ghc-prof-options: -fprof-auto-top -fprof-cafs
66+ hs-source-dirs: bin
67+ main-is: tutorial.hs
68+ ghc-options: -Wall -fwarn-incomplete-uni-patterns -rtsopts
8069
8170 if !flag(tutorial)
8271 buildable: False
72+
8373 else
84− build-depends: base
85− , cassava-streams
86− , io-streams
74+ build-depends:
75+ , base
76+ , cassava-streams
77+ , io-streams
8778
8879--------------------------------------------------------------------------------
8980test-suite test
90− type: exitcode-stdio-1.0
81+ import: dependencies
82+ type: exitcode-stdio-1.0
9183 default-language: Haskell2010
92− hs-source-dirs: test
93− main-is: test.hs
94− ghc-options: -Wall -fwarn-incomplete-uni-patterns
95−
96− if flag(maintainer)
97− ghc-options: -Werror
98−
99− build-depends: base
100− , QuickCheck >= 2.7 && < 3.0
101− , bytestring
102− , cassava
103− , cassava-streams
104− , io-streams
105− , tasty >= 0.8 && < 1.0
106− , tasty-quickcheck >= 0.8 && < 1.0
107− , vector
84+ hs-source-dirs: test
85+ main-is: test.hs
86+ ghc-options: -Wall -fwarn-incomplete-uni-patterns
87+ build-depends:
88+ , cassava-streams
89+ , QuickCheck >=2.7 && <3.0
90+ , tasty >=0.8 && <1.5
91+ , tasty-quickcheck >=0.8 && <1.3
data/HLint.hsnew file+3
@@ -0,0 +1,3 @@
1+module HLint.HLint where
2+import "hint" HLint.Builtin.All
3+ignore "Use import/export shortcut"
default.nixnew file+11
@@ -0,0 +1,11 @@
1+{ sources ? import ./nix/sources.nix
2+, pkgs ? import sources.nixpkgs { }
3+, nix-hs ? import sources.nix-hs { inherit pkgs; }
4+, ghc ? "default"
5+}:
6+
7+nix-hs {
8+ cabal = ./cassava-streams.cabal;
9+ flags = [ "tutorial" ];
10+ compiler = ghc;
11+}
nix/sources.jsonnew file+38
@@ -0,0 +1,38 @@
1+{
2+ "niv": {
3+ "branch": "master",
4+ "description": "Easy dependency management for Nix projects",
5+ "homepage": "https://github.com/nmattia/niv",
6+ "owner": "nmattia",
7+ "repo": "niv",
8+ "rev": "f73bf8d584148677b01859677a63191c31911eae",
9+ "sha256": "0jlmrx633jvqrqlyhlzpvdrnim128gc81q5psz2lpp2af8p8q9qs",
10+ "type": "tarball",
11+ "url": "https://github.com/nmattia/niv/archive/f73bf8d584148677b01859677a63191c31911eae.tar.gz",
12+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+ },
14+ "nix-hs": {
15+ "branch": "release-20.09",
16+ "description": "Haskell + nixpkgs = nix-hs",
17+ "homepage": "",
18+ "owner": "pjones",
19+ "repo": "nix-hs",
20+ "rev": "67163bb02a8791d79136ba6914b6d6dad594533b",
21+ "sha256": "0f7sjh45wxbf2m76l37f4l4v4dkq32dm599p85acx53324nr9y8z",
22+ "type": "tarball",
23+ "url": "https://github.com/pjones/nix-hs/archive/67163bb02a8791d79136ba6914b6d6dad594533b.tar.gz",
24+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+ },
26+ "nixpkgs": {
27+ "branch": "nixos-20.09",
28+ "description": "Nix Packages collection",
29+ "homepage": "",
30+ "owner": "NixOS",
31+ "repo": "nixpkgs",
32+ "rev": "edb26126d98bc696f4f3e206583faa65d3d6e818",
33+ "sha256": "1cl4ka4kk7kh3bl78g06dhiidazf65q8miyzaxi9930d6gwyzkci",
34+ "type": "tarball",
35+ "url": "https://github.com/NixOS/nixpkgs/archive/edb26126d98bc696f4f3e206583faa65d3d6e818.tar.gz",
36+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
37+ }
38+}
nix/sources.nixnew file+134
@@ -0,0 +1,134 @@
1+# This file has been generated by Niv.
2+
3+let
4+
5+ #
6+ # The fetchers. fetch_<type> fetches specs of type <type>.
7+ #
8+
9+ fetch_file = pkgs: spec:
10+ if spec.builtin or true then
11+ builtins_fetchurl { inherit (spec) url sha256; }
12+ else
13+ pkgs.fetchurl { inherit (spec) url sha256; };
14+
15+ fetch_tarball = pkgs: spec:
16+ if spec.builtin or true then
17+ builtins_fetchTarball { inherit (spec) url sha256; }
18+ else
19+ pkgs.fetchzip { inherit (spec) url sha256; };
20+
21+ fetch_git = spec:
22+ builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
23+
24+ fetch_builtin-tarball = spec:
25+ builtins.trace
26+ ''
27+ WARNING:
28+ The niv type "builtin-tarball" will soon be deprecated. You should
29+ instead use `builtin = true`.
30+
31+ $ niv modify <package> -a type=tarball -a builtin=true
32+ ''
33+ builtins_fetchTarball { inherit (spec) url sha256; };
34+
35+ fetch_builtin-url = spec:
36+ builtins.trace
37+ ''
38+ WARNING:
39+ The niv type "builtin-url" will soon be deprecated. You should
40+ instead use `builtin = true`.
41+
42+ $ niv modify <package> -a type=file -a builtin=true
43+ ''
44+ (builtins_fetchurl { inherit (spec) url sha256; });
45+
46+ #
47+ # Various helpers
48+ #
49+
50+ # The set of packages used when specs are fetched using non-builtins.
51+ mkPkgs = sources:
52+ let
53+ sourcesNixpkgs =
54+ import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
55+ hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
56+ hasThisAsNixpkgsPath = <nixpkgs> == ./.;
57+ in
58+ if builtins.hasAttr "nixpkgs" sources
59+ then sourcesNixpkgs
60+ else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
61+ import <nixpkgs> {}
62+ else
63+ abort
64+ ''
65+ Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
66+ add a package called "nixpkgs" to your sources.json.
67+ '';
68+
69+ # The actual fetching function.
70+ fetch = pkgs: name: spec:
71+
72+ if ! builtins.hasAttr "type" spec then
73+ abort "ERROR: niv spec ${name} does not have a 'type' attribute"
74+ else if spec.type == "file" then fetch_file pkgs spec
75+ else if spec.type == "tarball" then fetch_tarball pkgs spec
76+ else if spec.type == "git" then fetch_git spec
77+ else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
78+ else if spec.type == "builtin-url" then fetch_builtin-url spec
79+ else
80+ abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
81+
82+ # Ports of functions for older nix versions
83+
84+ # a Nix version of mapAttrs if the built-in doesn't exist
85+ mapAttrs = builtins.mapAttrs or (
86+ f: set: with builtins;
87+ listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
88+ );
89+
90+ # fetchTarball version that is compatible between all the versions of Nix
91+ builtins_fetchTarball = { url, sha256 }@attrs:
92+ let
93+ inherit (builtins) lessThan nixVersion fetchTarball;
94+ in
95+ if lessThan nixVersion "1.12" then
96+ fetchTarball { inherit url; }
97+ else
98+ fetchTarball attrs;
99+
100+ # fetchurl version that is compatible between all the versions of Nix
101+ builtins_fetchurl = { url, sha256 }@attrs:
102+ let
103+ inherit (builtins) lessThan nixVersion fetchurl;
104+ in
105+ if lessThan nixVersion "1.12" then
106+ fetchurl { inherit url; }
107+ else
108+ fetchurl attrs;
109+
110+ # Create the final "sources" from the config
111+ mkSources = config:
112+ mapAttrs (
113+ name: spec:
114+ if builtins.hasAttr "outPath" spec
115+ then abort
116+ "The values in sources.json should not have an 'outPath' attribute"
117+ else
118+ spec // { outPath = fetch config.pkgs name spec; }
119+ ) config.sources;
120+
121+ # The "config" used by the fetchers
122+ mkConfig =
123+ { sourcesFile ? ./sources.json
124+ , sources ? builtins.fromJSON (builtins.readFile sourcesFile)
125+ , pkgs ? mkPkgs sources
126+ }: rec {
127+ # The sources, i.e. the attribute set of spec name to spec
128+ inherit sources;
129+
130+ # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
131+ inherit pkgs;
132+ };
133+in
134+mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
shell.nixnew file+2
@@ -0,0 +1,2 @@
1+# Load an interactive environment:
2+(import ./. {}).interactive
src/System/IO/Streams/Csv/Decode.hs+2−2
@@ -1,4 +1,4 @@
1−{-# LANGUAGE DeriveDataTypeable #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
22{-# LANGUAGE ScopedTypeVariables #-}
33
44{-
@@ -37,7 +37,7 @@ import qualified System.IO.Streams as Streams
3737--------------------------------------------------------------------------------
3838-- | Exception thrown when stream decoding cannot continue due to an
3939-- error.
40−data StreamDecodingError = StreamDecodingError String
40+newtype StreamDecodingError = StreamDecodingError String
4141 deriving (Typeable, Show)
4242
4343instance Exception StreamDecodingError
test/test.hs+1−1
@@ -70,7 +70,7 @@ roundTrip is os recs = do
7070 Streams.connect sourceList encoder
7171
7272 -- Decode from ByteString.
73− decoder <- fmap BS.concat encoded >>= Streams.fromByteString >>= is
73+ decoder <- (encoded >>= Streams.fromByteString . BS.concat) >>= is
7474 (decodeStream, decoded) <- Streams.listOutputStream
7575 Streams.connect decoder decodeStream
7676 decoded