Skip to content

Commit

Permalink
Initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 28, 2016
1 parent f9c45d2 commit 3d36a36
Show file tree
Hide file tree
Showing 18 changed files with 552 additions and 23 deletions.
14 changes: 10 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dist
dist-*
dist-newstyle
cabal-dev
*.o
*.hi
Expand All @@ -14,6 +14,12 @@ cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local

/*.submodules
/.stack-work/
/result
/deps
/stack.yaml
/*.json
/*.json.ib
/*.json.bp
39 changes: 20 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
BSD 3-Clause License
Copyright John Ky (c) 2016

Copyright (c) 2016,
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
* Neither the name of Author name here nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# hw-packed-vector
[![CircleCI](https://circleci.com/gh/haskell-works/hw-packed-vector/tree/0-branch.svg?style=svg)](https://circleci.com/gh/haskell-works/hw-packed-vector/tree/0-branch)

A vector that stores words of equal size between 1 to 64 inclusive in memory contiguously
with efficient lookup.

2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
28 changes: 28 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
dependencies:
cache_directories:
- "~/.cabal"
- "~/.stack"
pre:
- wget -qO- https://get.haskellstack.org/ | sh
- cp ./scripts/* ~/bin/
override:
- fetch
- stack init --resolver lts-7.2
- stack build --only-dependencies

test:
override:
- stack test

deployment:
release_branch:
owner: haskell-works
branch: /.*-branch/
commands:
- when tag autotag

hackage:
owner: haskell-works
tag: /v.*/
commands:
- publish
53 changes: 53 additions & 0 deletions hw-packed-vector.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: hw-packed-vector
version: 0.0.0.1
synopsis: Packed Vector
description: Please see README.md
homepage: http://github.com/haskell-works/hw-packed-vector#readme
license: BSD3
license-file: LICENSE
author: John Ky
maintainer: newhoggy@gmail.com
copyright: 2016 John Ky
category: Data, Vector
stability: Experimental
build-type: Simple
extra-source-files: README.md
cabal-version: >= 1.22

library
hs-source-dirs: src
exposed-modules: HaskellWorks.Data.PackedVector
, HaskellWorks.Data.PackedVector.Internal
, HaskellWorks.Data.PackedVector.PackedVector64
build-depends: base >= 4 && < 5
, bytestring
, hw-bits >= 0.4.0.0
, hw-int >= 0.0.0.1
, hw-prim >= 0.4.0.0
, hw-string-parse >= 0.0.0.1
, safe
, vector

default-language: Haskell2010
ghc-options: -Wall -O2 -msse4.2

test-suite hw-packed-vector-test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Spec.hs
other-modules: HaskellWorks.Data.PackedVector.PackedVector64Spec
, HaskellWorks.Data.PackedVector.InternalSpec
build-depends: base >= 4 && < 5
, bytestring
, hspec
, hw-bits >= 0.4.0.0
, hw-packed-vector
, hw-prim >= 0.4.0.0
, QuickCheck
, vector
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
default-language: Haskell2010

source-repository head
type: git
location: https://github.com/haskell-works/hw-packed-vector
46 changes: 46 additions & 0 deletions scripts/autotag
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

if [ "$_system_type" == "Darwin" ]; then
sed () {
gsed "$@"
}
fi

_repo_name=$(basename `git rev-parse --show-toplevel`)

_version=$(
cat $_repo_name.cabal | grep '^version:' | head | cut -d ':' -f 2 | xargs
)

_branch=$(git rev-parse --abbrev-ref HEAD)
_branch_prefix=${_branch%-branch}

if [[ "$_version" != "$_branch_prefix".* ]]; then
echo "The version $_version does not belong to the branch $_branch"
exit 1
fi

if [[ $(git ls-remote origin "refs/tags/v$_version") ]]; then
echo "The tag v$_version already exists. Will not tag"
exit 0
fi

_commit=$(git rev-parse --verify HEAD)

_release_data=$(cat <<EOF
{
"tag_name": "v$_version",
"target_commitish": "$_commit",
"name": "v$_version",
"body": "New release",
"draft": false,
"prerelease": false
}
EOF
)

echo "Creating release v$_version from commit $_commit in branch $_branch"

curl -H "Authorization: token $GITHUB_TOKEN" \
-X POST https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases \
--data "$_release_data"
29 changes: 29 additions & 0 deletions scripts/fetch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

cabal update

mkdir -p deps

_project="$(echo *.cabal | cut -d '.' -f 1)"

direct_deps() {
cat *.cabal | grep ', hw-' | cut -d , -f 2 | cut -d ' ' -f 2 | sort | uniq | grep -v "$_project"
}

pushd deps > /dev/null

cp ../$_project.cabal ./

projects() {
for x in $(direct_deps | sort | uniq); do
cabal install $x --dry-run | grep hw- | grep -v "^${_project}-[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$"
done
}

for x in $(projects | sort | uniq); do
cabal unpack $x
done

rm ./$_project.cabal

popd > /dev/null
34 changes: 34 additions & 0 deletions scripts/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

if [ "$_system_type" == "Darwin" ]; then
sed () {
gsed "$@"
}
fi

if [ "$HACKAGE_USER" == "" ] || [ "$HACKAGE_PASS" == "" ]; then
echo "Must supply credentials"
exit 1
fi

_repo_name=$(basename `git rev-parse --show-toplevel`)

_version=$(
cat $_repo_name.cabal | grep '^version:' | head | cut -d ':' -f 2 | xargs
)

if [ "v$_version" != "$CIRCLE_TAG" ]; then
echo "Tag mismatch: "v$_version != $CIRCLE_TAG""
exit 1
fi

cabal configure

cabal sdist

if [ "$ALLOW_UPLOAD" != "" ]; then
cabal upload \
--username=$HACKAGE_USER \
--password=$HACKAGE_PASS \
"dist/${_repo_name}-${_version}.tar.gz"
fi
9 changes: 9 additions & 0 deletions scripts/setup-cred
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

cred=~/.stack/upload/credentials.json
if [ ! -f "${cred}" ]; then
if [ ! -e ~/.stack/upload ]; then
mkdir -p ~/.stack/upload
fi
echo "{\"username\":\"${HACKAGE_USER}\",\"password\":\"${HACKAGE_PASS}\"}" > ${cred}
fi
71 changes: 71 additions & 0 deletions scripts/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

if [ "$_system_type" == "Darwin" ]; then
sed () {
gsed "$@"
}
fi

_repo_name=$(basename `git rev-parse --show-toplevel`)

_version=$(
cat $_repo_name.cabal | grep '^version:' | head | cut -d ':' -f 2 | xargs
)

_major=$(
echo $_version | sed 's|^\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)|\1|g'
)

_minor=$(
echo $_version | sed 's|^\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)|\2|g'
)

_point=$(
echo $_version | sed 's|^\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)|\3|g'
)

_patch=$(
echo $_version | sed 's|^\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)|\4|g'
)


case $1 in
major)
_new_version="$(($_major + 1)).0.0.0"
_new_branch="$(($_major + 1))"
;;
minor)
_new_version="$_major.$(($_minor + 1)).0.0"
;;
point)
_new_version="$_major.$_minor.$(($_point + 1)).0"
;;
patch)
_new_version="$_major.$_minor.$_point.$(($_patch + 1))"
;;
*)
echo "./scripts/up (major|minor|point|patch)"
exit 1
esac

sed "s|^\(version:\s*\)\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)$|\1$_new_version|g" -i $_repo_name.cabal

echo "Cabal project version upgrade to $_new_version"
echo ""
echo "Please review and run the following commands:"
echo ""

if [ "$_new_branch" != "" ]; then
echo " git checkout -b ${_new_branch}-branch"
fi

echo " git add $_repo_name.cabal"
echo " git commit -m 'New version $_new_version'"

if [ "$_new_branch" != "" ]; then
echo " git push --set-upstream origin ${_new_branch}-branch"
else
echo " git push origin"
fi

echo ""
18 changes: 18 additions & 0 deletions scripts/when
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e

_expected_stage="$1"

if [ "$BUILD_STAGES" == "" ]; then
BUILD_STAGES=all
fi

for stage in $BUILD_STAGES; do
if [ "$stage" == "$_expected_stage" ] || [ "$stage" == "all" ]; then
shift 1
"$@"

break
fi
done
8 changes: 8 additions & 0 deletions src/HaskellWorks/Data/PackedVector.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE MultiParamTypeClasses #-}

module HaskellWorks.Data.PackedVector
( module X
) where

import HaskellWorks.Data.PackedVector.Internal as X
import HaskellWorks.Data.PackedVector.PackedVector64 as X
Loading

0 comments on commit 3d36a36

Please sign in to comment.