Skip to content

Commit 1700da1

Browse files
committed
Initial commit
1 parent 92f6078 commit 1700da1

File tree

17 files changed

+567
-22
lines changed

17 files changed

+567
-22
lines changed

.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dist
2-
dist-*
2+
dist-newstyle
33
cabal-dev
44
*.o
55
*.hi
@@ -14,6 +14,9 @@ cabal.sandbox.config
1414
*.prof
1515
*.aux
1616
*.hp
17-
*.eventlog
18-
.stack-work/
19-
cabal.project.local
17+
18+
/*.submodules
19+
/.stack-work/
20+
/*.nix
21+
/*.nix.part
22+
/result

LICENSE

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
MIT License
1+
Copyright John Ky (c) 2016
22

3-
Copyright (c) 2016
3+
All rights reserved.
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
117

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
1410

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
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 Author name here 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.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# hw-nanoparsec
1+
# hw-string-parse
2+
[![CircleCI](https://circleci.com/gh/haskell-works/hw-string-parse/tree/0-branch.svg?style=svg)](https://circleci.com/gh/haskell-works/hw-string-parse/tree/0-branch)
3+
4+
Simple parser combinator library for strings.

Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

circle.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
machine:
2+
post:
3+
- curl https://nixos.org/nix/install | sh
4+
5+
dependencies:
6+
cache_directories:
7+
- "~/.cabal"
8+
- "~/.ghc"
9+
pre:
10+
- cp ./scripts/* ~/bin/
11+
override:
12+
# Fix to latest stable release
13+
# - nox nix-channel --add https://nixos.org/channels/nixos-16.03/ nixpkgs
14+
# - nox nix-channel --update
15+
- nox when deps nix-mk
16+
- nox when deps nix-deps
17+
18+
test:
19+
override:
20+
- nox when build nix-build
21+
22+
deployment:
23+
release_branch:
24+
owner: haskell-works
25+
branch: /.*-branch/
26+
commands:
27+
- nox when tag autotag
28+
29+
hackage:
30+
owner: haskell-works
31+
tag: /v.*/
32+
commands:
33+
- nox when deploy nix-shell shell.nix --command publish

hw-string-parse.cabal

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: hw-string-parse
2+
version: 0.0.0.1
3+
synopsis: Conduits for tokenizing streams.
4+
description: Please see README.md
5+
homepage: http://github.com/haskell-works/hw-string-parse#readme
6+
license: MIT
7+
license-file: LICENSE
8+
author: John Ky
9+
maintainer: [email protected]
10+
copyright: 2016 John Ky
11+
category: Data, Bit
12+
stability: Experimental
13+
build-type: Simple
14+
extra-source-files: README.md
15+
cabal-version: >= 1.22
16+
17+
library
18+
hs-source-dirs: src
19+
exposed-modules: HaskellWorks.Data.String.Parse
20+
build-depends: base >= 4 && < 5
21+
22+
default-language: Haskell2010
23+
ghc-options: -Wall -O2 -msse4.2
24+
25+
test-suite hw-string-parse-test
26+
type: exitcode-stdio-1.0
27+
hs-source-dirs: test
28+
main-is: Spec.hs
29+
other-modules:
30+
build-depends: base >= 4 && < 5
31+
, bytestring
32+
, hspec
33+
, hw-string-parse
34+
, QuickCheck
35+
, vector
36+
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
37+
default-language: Haskell2010
38+
39+
source-repository head
40+
type: git
41+
location: https://github.com/haskell-works/hw-string-parse

mafia

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/sh -eu
2+
3+
fetch_latest () {
4+
if [ -z ${MAFIA_TEST_MODE+x} ]; then
5+
TZ=$(date +"%T")
6+
curl --silent "https://raw.githubusercontent.com/ambiata/mafia/master/script/mafia?$TZ"
7+
else
8+
cat ../script/mafia
9+
fi
10+
}
11+
12+
latest_version () {
13+
git ls-remote https://github.com/ambiata/mafia | grep refs/heads/master | cut -f 1
14+
}
15+
16+
local_version () {
17+
awk '/^# Version: / { print $3; exit 0; }' $0
18+
}
19+
20+
run_upgrade () {
21+
MAFIA_TEMP=$(mktemp 2>/dev/null || mktemp -t 'upgrade_mafia')
22+
23+
clean_up () {
24+
rm -f "$MAFIA_TEMP"
25+
}
26+
27+
trap clean_up EXIT
28+
29+
MAFIA_CUR="$0"
30+
31+
if [ -L "$MAFIA_CUR" ]; then
32+
echo 'Refusing to overwrite a symlink; run `upgrade` from the canonical path.' >&2
33+
exit 1
34+
fi
35+
36+
echo "Checking for a new version of mafia ..."
37+
fetch_latest > $MAFIA_TEMP
38+
39+
LATEST_VERSION=$(latest_version)
40+
echo "# Version: $LATEST_VERSION" >> $MAFIA_TEMP
41+
42+
if ! cmp $MAFIA_CUR $MAFIA_TEMP >/dev/null 2>&1; then
43+
mv $MAFIA_TEMP $MAFIA_CUR
44+
chmod +x $MAFIA_CUR
45+
echo "New version found and upgraded. You can now commit it to your git repo."
46+
else
47+
echo "You have latest mafia."
48+
fi
49+
}
50+
51+
exec_mafia () {
52+
MAFIA_VERSION=$(local_version)
53+
54+
if [ "x$MAFIA_VERSION" = "x" ]; then
55+
# If we can't find the mafia version, then we need to upgrade the script.
56+
run_upgrade
57+
else
58+
MAFIA_BIN=$HOME/.ambiata/mafia/bin
59+
MAFIA_FILE=mafia-$MAFIA_VERSION
60+
MAFIA_PATH=$MAFIA_BIN/$MAFIA_FILE
61+
62+
[ -f "$MAFIA_PATH" ] || {
63+
# Create a temporary directory which will be deleted when the script
64+
# terminates. Unfortunately `mktemp` doesn't behave the same on
65+
# Linux and OS/X so we need to try two different approaches.
66+
MAFIA_TEMP=$(mktemp -d 2>/dev/null || mktemp -d -t 'exec_mafia')
67+
68+
# Create a temporary file in MAFIA_BIN so we can do an atomic copy/move dance.
69+
mkdir -p $MAFIA_BIN
70+
71+
clean_up () {
72+
rm -rf "$MAFIA_TEMP"
73+
}
74+
75+
trap clean_up EXIT
76+
77+
echo "Building $MAFIA_FILE in $MAFIA_TEMP"
78+
79+
( cd "$MAFIA_TEMP"
80+
81+
git clone https://github.com/ambiata/mafia
82+
cd mafia
83+
84+
git reset --hard $MAFIA_VERSION
85+
86+
bin/bootstrap ) || exit $?
87+
88+
MAFIA_PATH_TEMP=$(mktemp --tmpdir=$MAFIA_BIN $MAFIA_FILE-XXXXXX 2>/dev/null || TMPDIR=$MAFIA_BIN mktemp -t $MAFIA_FILE)
89+
90+
clean_up_temp () {
91+
clean_up
92+
rm -f "$MAFIA_PATH_TEMP"
93+
}
94+
trap clean_up_temp EXIT
95+
96+
cp "$MAFIA_TEMP/mafia/.cabal-sandbox/bin/mafia" "$MAFIA_PATH_TEMP"
97+
chmod 755 "$MAFIA_PATH_TEMP"
98+
mv "$MAFIA_PATH_TEMP" "$MAFIA_PATH"
99+
100+
clean_up_temp
101+
}
102+
103+
exec $MAFIA_PATH "$@"
104+
fi
105+
}
106+
107+
#
108+
# The actual start of the script.....
109+
#
110+
111+
if [ $# -gt 0 ]; then
112+
MODE="$1"
113+
else
114+
MODE=""
115+
fi
116+
117+
case "$MODE" in
118+
upgrade) shift; run_upgrade "$@" ;;
119+
*) exec_mafia "$@"
120+
esac
121+
# Version: de245376fd86c1ec9a5a451f096cb79bc8ae68f7

packages.list

Whitespace-only changes.

scripts/autotag

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
if [ "$_system_type" == "Darwin" ]; then
4+
sed () {
5+
gsed "$@"
6+
}
7+
fi
8+
9+
_repo_name=$(basename `git rev-parse --show-toplevel`)
10+
11+
_version=$(
12+
cat $_repo_name.cabal | grep '^version:' | head | cut -d ':' -f 2 | xargs
13+
)
14+
15+
_branch=$(git rev-parse --abbrev-ref HEAD)
16+
_branch_prefix=${_branch%-branch}
17+
18+
if [[ "$_version" != "$_branch_prefix".* ]]; then
19+
echo "The version $_version does not belong to the branch $_branch"
20+
exit 1
21+
fi
22+
23+
if [[ $(git ls-remote origin "refs/tags/v$_version") ]]; then
24+
echo "The tag v$_version already exists. Will not tag"
25+
exit 0
26+
fi
27+
28+
_commit=$(git rev-parse --verify HEAD)
29+
30+
_release_data=$(cat <<EOF
31+
{
32+
"tag_name": "v$_version",
33+
"target_commitish": "$_commit",
34+
"name": "v$_version",
35+
"body": "New release",
36+
"draft": false,
37+
"prerelease": false
38+
}
39+
EOF
40+
)
41+
42+
echo "Creating release v$_version from commit $_commit in branch $_branch"
43+
44+
curl -H "Authorization: token $GITHUB_TOKEN" \
45+
-X POST https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases \
46+
--data "$_release_data"

scripts/nix-deps

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
nix-shell -E '(import <nixpkgs> {}).haskellPackages.callPackage ./shell.nix {}' --run "echo Initialised dependencies"
4+
5+
nix-env -i cabal-install "$@"

scripts/nix-mk

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
3+
repo_name="$(basename `git rev-parse --show-toplevel`)"
4+
ghc_attr_namever="ghc7103"
5+
6+
nix-env -i cabal2nix
7+
8+
cabal update
9+
10+
cabal2nix . > "$repo_name".nix
11+
12+
cat > default.nix <<EOF
13+
{ nixpkgs ? import <nixpkgs> {}, compiler ? "$ghc_attr_namever" }:
14+
nixpkgs.pkgs.haskell.packages.\${compiler}.callPackage ./$repo_name.nix { }
15+
EOF
16+
17+
cat > shell.nix <<EOF
18+
{ nixpkgs ? import <nixpkgs> {}, compiler ? "$ghc_attr_namever" }:
19+
(import ./default.nix { inherit nixpkgs compiler; }).env
20+
EOF
21+
22+
if [ "$CI" == "true" ]; then
23+
config_nix=~/.nixpkgs/config.nix
24+
else
25+
config_nix=~/.nixpkgs/config.nix.gen
26+
fi
27+
28+
if [ -f packages.list ]; then
29+
mkdir -p ~/.nixpkgs
30+
rm -f package_config.nix.part
31+
touch package_config.nix.part
32+
33+
for package in $(cat packages.list | grep -v "^$repo_name\$"); do
34+
cabal2nix cabal://$package > $package.nix
35+
package_version="$(cat $package.nix | grep '^ *version *=' | head -n 1 | cut -d = -f 2 | cut -d '"' -f 2)"
36+
mv $package.nix ~/.nixpkgs/$package-$package_version.nix
37+
echo " $package = self.callPackage ./$package-$package_version.nix {};" >> package_config.nix.part
38+
echo " # $package = self.callPackage ~/wrk/haskell-works/hw-all/$package {};" >> package_config.nix.part
39+
done
40+
41+
cat > "$config_nix" <<EOF
42+
{
43+
packageOverrides = super: let self = super.pkgs; in
44+
{
45+
haskell = super.haskell // {
46+
packages = super.haskell.packages // {
47+
$ghc_attr_namever = super.haskell.packages.$ghc_attr_namever.override {
48+
overrides = self: super: {
49+
$(cat package_config.nix.part)
50+
};
51+
};
52+
};
53+
};
54+
};
55+
}
56+
EOF
57+
fi

0 commit comments

Comments
 (0)