Skip to content

Commit 72c42b8

Browse files
committed
initial commit
0 parents  commit 72c42b8

9 files changed

+471
-0
lines changed

Diff for: .gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
other/* linguist-documentation
2+
index.html linguist-documentation

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.stack-work/
2+
TAGS

Diff for: .travis.yml

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
## modified version of the complex Travis configuration.
2+
# For more information and other options, see:
3+
#
4+
# https://docs.haskellstack.org/en/stable/travis_ci/
5+
#
6+
7+
# Use new container infrastructure to enable caching
8+
sudo: false
9+
10+
# Do not choose a language; we provide our own build tools.
11+
language: generic
12+
13+
# Caching so the next build will be fast too.
14+
cache:
15+
directories:
16+
- $HOME/.ghc
17+
- $HOME/.cabal
18+
- $HOME/.stack
19+
20+
# The different configurations we want to test. We have BUILD=cabal which uses
21+
# cabal-install, and BUILD=stack which uses Stack. More documentation on each
22+
# of those below.
23+
#
24+
# We set the compiler values here to tell Travis to use a different
25+
# cache file per set of arguments.
26+
#
27+
# If you need to have different apt packages for each combination in the
28+
# matrix, you can use a line such as:
29+
# addons: {apt: {packages: [libfcgi-dev,libgmp-dev]}}
30+
matrix:
31+
include:
32+
# We grab the appropriate GHC and cabal-install versions from hvr's PPA. See:
33+
# https://github.com/hvr/multi-ghc-travis
34+
- env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 HAPPYVER=1.19.5 ALEXVER=3.1.7
35+
compiler: ": #GHC 7.10.3"
36+
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
37+
- env: BUILD=cabal GHCVER=8.0.1 CABALVER=1.24 HAPPYVER=1.19.5 ALEXVER=3.1.7
38+
compiler: ": #GHC 8.0.1"
39+
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
40+
41+
# Build with the newest GHC and cabal-install. This is an accepted failure,
42+
# see below.
43+
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
44+
compiler: ": #GHC HEAD"
45+
addons: {apt: {packages: [cabal-install-head,ghc-head,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc]}}
46+
47+
# The Stack builds. We can pass in arbitrary Stack arguments via the ARGS
48+
# variable, such as using --stack-yaml to point to a different file.
49+
- env: BUILD=stack ARGS="--resolver lts-6"
50+
compiler: ": #stack 7.10.3"
51+
addons: {apt: {packages: [libgmp-dev]}}
52+
53+
- env: BUILD=stack ARGS="--resolver lts-7"
54+
compiler: ": #stack 8.0.1"
55+
addons: {apt: {packages: [libgmp-dev]}}
56+
57+
# Nightly builds are allowed to fail
58+
- env: BUILD=stack ARGS="--resolver nightly"
59+
compiler: ": #stack nightly"
60+
addons: {apt: {packages: [libgmp-dev]}}
61+
62+
# Build on macOS in addition to Linux
63+
- env: BUILD=stack ARGS="--resolver lts-7"
64+
compiler: ": #stack 8.0.1 osx"
65+
os: osx
66+
67+
allow_failures:
68+
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
69+
- env: BUILD=stack ARGS="--resolver nightly"
70+
71+
72+
before_install:
73+
# Using compiler above sets CC to an invalid value, so unset it
74+
- unset CC
75+
76+
# We want to always allow newer versions of packages when building on GHC HEAD
77+
- CABALARGS=""
78+
- if [ "x$GHCVER" = "xhead" ]; then CABALARGS=--allow-newer; fi
79+
80+
# Download and unpack the stack executable
81+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:/opt/alex/$ALEXVER/bin:/opt/happy/$HAPPYVER/bin:$HOME/.cabal/bin:$PATH
82+
- mkdir -p ~/.local/bin
83+
- |
84+
if [ `uname` = "Darwin" ]
85+
then
86+
travis_retry curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
87+
else
88+
travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
89+
fi
90+
91+
# Use the more reliable S3 mirror of Hackage
92+
mkdir -p $HOME/.cabal
93+
echo 'remote-repo: hackage.haskell.org:http://hackage.fpcomplete.com/' > $HOME/.cabal/config
94+
echo 'remote-repo-cache: $HOME/.cabal/packages' >> $HOME/.cabal/config
95+
96+
if [ "$CABALVER" != "1.16" ]
97+
then
98+
echo 'jobs: $ncpus' >> $HOME/.cabal/config
99+
fi
100+
101+
install:
102+
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
103+
- if [ -f configure.ac ]; then autoreconf -i; fi
104+
- |
105+
set -ex
106+
case "$BUILD" in
107+
stack)
108+
stack --no-terminal --install-ghc $ARGS test --bench --only-dependencies
109+
;;
110+
cabal)
111+
cabal --version
112+
travis_retry cabal update
113+
114+
# Get the list of packages from the stack.yaml file
115+
PACKAGES=$(stack --install-ghc query locals | grep '^ *path' | sed 's@^ *path:@@')
116+
117+
cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES
118+
;;
119+
esac
120+
set +ex
121+
122+
script:
123+
- |
124+
set -ex
125+
case "$BUILD" in
126+
stack)
127+
stack --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
128+
;;
129+
cabal)
130+
cabal install --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES
131+
132+
ORIGDIR=$(pwd)
133+
for dir in $PACKAGES
134+
do
135+
cd $dir
136+
cabal check || [ "$CABALVER" == "1.16" ]
137+
cabal sdist
138+
PKGVER=$(cabal info . | awk '{print $2;exit}')
139+
SRC_TGZ=$PKGVER.tar.gz
140+
cd dist
141+
tar zxfv "$SRC_TGZ"
142+
cd "$PKGVER"
143+
cabal configure --enable-tests
144+
cabal build
145+
cd $ORIGDIR
146+
done
147+
;;
148+
esac
149+
set +ex

Diff for: LICENSE

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright Tony Day (c) 2017
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Tony Day nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Diff for: Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

Diff for: data-haskell-examples.cabal

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name:
2+
data-haskell-examples
3+
version:
4+
0.1.0.0
5+
synopsis:
6+
Data analysis examples
7+
description:
8+
A set of recommended Haskell libraries for data analysis and example usage.
9+
category:
10+
project
11+
homepage:
12+
https://github.com/DataHaskell/data-haskell-examples
13+
license:
14+
BSD3
15+
license-file:
16+
LICENSE
17+
author:
18+
Tony Day
19+
maintainer:
20+
21+
copyright:
22+
Tony Day
23+
build-type:
24+
Simple
25+
cabal-version:
26+
>=1.14
27+
extra-source-files:
28+
stack.yaml
29+
library
30+
default-language:
31+
Haskell2010
32+
ghc-options:
33+
hs-source-dirs:
34+
35+
exposed-modules:
36+
37+
build-depends:
38+
base >= 4.7 && < 5
39+
default-extensions:
40+
NoImplicitPrelude,
41+
UnicodeSyntax,
42+
BangPatterns,
43+
BinaryLiterals,
44+
DeriveFoldable,
45+
DeriveFunctor,
46+
DeriveGeneric,
47+
DeriveTraversable,
48+
DisambiguateRecordFields,
49+
EmptyCase,
50+
FlexibleContexts,
51+
FlexibleInstances,
52+
FunctionalDependencies,
53+
GADTSyntax,
54+
InstanceSigs,
55+
KindSignatures,
56+
LambdaCase,
57+
MonadComprehensions,
58+
MultiParamTypeClasses,
59+
MultiWayIf,
60+
NegativeLiterals,
61+
OverloadedStrings,
62+
ParallelListComp,
63+
PartialTypeSignatures,
64+
PatternSynonyms,
65+
RankNTypes,
66+
RecordWildCards,
67+
RecursiveDo,
68+
ScopedTypeVariables,
69+
TupleSections,
70+
TypeFamilies,
71+
TypeOperators
72+
73+
executable data-haskell-examples
74+
default-language:
75+
Haskell2010
76+
ghc-options:
77+
-funbox-strict-fields
78+
-fforce-recomp
79+
-threaded
80+
-rtsopts
81+
-with-rtsopts=-N
82+
hs-source-dirs:
83+
examples
84+
main-is:
85+
examples.hs
86+
build-depends:
87+
base >= 4.7 && < 5,
88+
protolude,
89+
data-haskell-examples,
90+
vector
91+
default-extensions:
92+
NoImplicitPrelude,
93+
UnicodeSyntax,
94+
BangPatterns,
95+
BinaryLiterals,
96+
DeriveFoldable,
97+
DeriveFunctor,
98+
DeriveGeneric,
99+
DeriveTraversable,
100+
DisambiguateRecordFields,
101+
EmptyCase,
102+
FlexibleContexts,
103+
FlexibleInstances,
104+
FunctionalDependencies,
105+
GADTSyntax,
106+
InstanceSigs,
107+
KindSignatures,
108+
LambdaCase,
109+
MonadComprehensions,
110+
MultiParamTypeClasses,
111+
MultiWayIf,
112+
NegativeLiterals,
113+
OverloadedStrings,
114+
ParallelListComp,
115+
PartialTypeSignatures,
116+
PatternSynonyms,
117+
RankNTypes,
118+
RecordWildCards,
119+
RecursiveDo,
120+
ScopedTypeVariables,
121+
TupleSections,
122+
TypeFamilies,
123+
TypeOperators
124+
125+
source-repository head
126+
type:
127+
git
128+
location:
129+
https://github.com/DataHaskell/data-haskell-examples

Diff for: examples/examples.hs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import Protolude
2+
import Data.Vector as V
3+
4+
main :: IO ()
5+
main = do
6+
-- vector examples
7+
let x = V.fromList [0..5]
8+
9+
print $ V.length x -- 6
10+
print $ V.null x -- False
11+
12+
-- indexing
13+
print $ x ! 1 -- 1
14+
print $ V.head x -- 0
15+
print $ last x -- 5
16+
17+
-- Slicing
18+
print $ slice 2 3 x -- [2, 3, 4]
19+
print $ V.splitAt 2 x -- ([0, 1], [2, 3, 4, 5])
20+
21+
-- Prepending and Appending
22+
print $ cons (-1) x -- [-1, 0, 1, 2, 3, 4, 5]
23+
print $ snoc x 6 -- [0, 1, 2, 3, 4, 5, 6]
24+
25+
-- Concatenation
26+
print $ x V.++ x -- [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]
27+
print $ V.concat [x, x] -- [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]
28+
29+
-- Update
30+
print $ x // [(0, 1), (2, 6)] -- [1, 1, 6, 3, 4, 5]
31+
print $ V.map (+2) x -- [2, 3, 4, 5, 6, 7]

0 commit comments

Comments
 (0)