Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor model for actions #129

Merged
merged 12 commits into from
Mar 14, 2019
90 changes: 46 additions & 44 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
# https://serokell.io/posts/2018-01-24-using-travis-CI-for-Haskell-projects.html
# also see:
# https://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix
# https://docs.haskellstack.org/en/stable/travis_ci/
# https://github.com/commercialhaskell/stack/blob/master/.travis.yml
# https://github.com/ekmett/intervals/blob/master/.travis.yml

sudo: true

language: haskell
dist: trusty

# Caching so the next build will be fast too.
cache:
directories:
- $HOME/.stack
- $HOME/build/tonyday567/numhask/.stack-work

ghc:
- head
# - 8.6.1
- 8.4.3
- $TRAVIS_BUILD_DIR/.stack-work

env:
- PACKAGEDIR="numhask"
- PACKAGEDIR="numhask-prelude"
- PACKAGEDIR="numhask-array"
- PACKAGEDIR="numhask-hedgehog"
cabal: "2.4"

matrix:
allow_failures:
- ghc: head
- ghc: ghc-8.6.1

# Ensure necessary system libraries are present
addons:
apt:
sources:
- sourceline: 'ppa:hvr/ghc' # PPA of Haskell packages
packages:
- libgmp-dev # required by cabal
- cabal-install-2.2 # required by GHC 8.*
- cabal-install-head # required by GHC head
include:
- env: ARGS="--resolver lts-13.11 --system-ghc"
ghc: "8.6.3"
# a -Werror build that is allowed to fail
- env: BUILD=werror ARGS="--resolver lts-13.11 --system-ghc"
ghc: "8.6.3"
- env: BUILD=stack ARGS="--resolver nightly --system-ghc"
ghc: "8.6.4"

before_install:
- cd ${PACKAGEDIR}
allow_failures:
- env: BUILD=stack ARGS="--resolver nightly --system-ghc"
- env: BUILD=werror ARGS="--resolver lts-13.11 --system-ghc"

install:
# Download and unpack the stack executable
- mkdir -p ~/.local/bin
- export PATH=$HOME/.local/bin:$PATH
- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
# Build dependencies
- stack --no-terminal --install-ghc test --only-dependencies
- |
case "$BUILD" in
cabal)
cabal --version
ghc --version
;;
stack|werror)
ghc --version
PATH=$HOME/.local/bin:$PATH
mkdir -p ~/.local/bin
if [ `uname` = "Darwin" ]
then
travis_retry curl --insecure -L https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
else
travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
fi
;;
esac

script:
# Build the package, its tests, and its docs and run the tests
- stack --no-terminal test --haddock --no-haddock-deps
- |
case "$BUILD" in
cabal)
cabal v2-update
cabal v2-build
cabal v2-test --enable-test
;;
stack)
stack --no-terminal $ARGS test --haddock --no-haddock-deps
;;
werror)
stack --no-terminal $ARGS test --haddock --no-haddock-deps --ghc-options -Werror --ghc-options -Wcompat --ghc-options -Wincomplete-record-updates --ghc-options -Wincomplete-uni-patterns --ghc-options -Wredundant-constraints
;;
esac
4 changes: 0 additions & 4 deletions hunit-numhask/.gitignore

This file was deleted.

34 changes: 0 additions & 34 deletions hunit-numhask/.travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions hunit-numhask/README.md

This file was deleted.

9 changes: 3 additions & 6 deletions hunit-numhask/hunit-numhask.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ category:
Test
build-type:
Simple
extra-source-files:
README.md
cabal-version:
>=1.18
tested-with:
GHC == 8.4.1

library
default-language: Haskell2010
ghc-options:
Expand All @@ -36,7 +33,6 @@ library
, exceptions
, HUnit
, numhask

test-suite spec
default-language: Haskell2010
ghc-options:
Expand All @@ -54,9 +50,10 @@ test-suite spec
, hunit-numhask
, hspec
, QuickCheck

source-repository head
type:
git
location:
https://github.com/githubuser/hunit-numhask
https://github.com/tonyday567/numhask
subdir:
hunit-numhask
8 changes: 0 additions & 8 deletions hunit-numhask/stack.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion hunit-numhask/test/LibSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ spec :: Spec
spec =
describe "Test.HUnit.NumHask" $ do
it "Tests Float values for approximate equality" $
(1/3 :: Float) `shouldBeAbout` 0.333333
(1/3 :: Float) `shouldBeAbout` 0.33333334
it "Tests Double values for approximate equality" $
(1/3 :: Double) `shouldBeAbout` 0.3333333333333333
16 changes: 6 additions & 10 deletions numhask-array/numhask-array.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ build-type:
Simple
cabal-version:
>= 1.18

extra-source-files:
stack.yaml

source-repository head
type:
git
location:
https://github.com/tonyday567/numhask-array

https://github.com/tonyday567/numhask
subdir:
numhask-array
library
hs-source-dirs:
src
Expand All @@ -51,14 +48,14 @@ library
-Wincomplete-uni-patterns
-Wredundant-constraints
build-depends:
base >=4.11 && <4.12
base >=4.11 && <4.13
, adjunctions >=4.0 && <5
, deepseq >=1.4.2.0 && <2
, dimensions >=0.3.2.0 && <0.4
, distributive >=0.4 && <0.6
, numhask-prelude >=0.3 && <0.4
, numhask-prelude
, numhask-hedgehog
, protolude >=0.1 && <0.3
, protolude
, singletons >=2.0 && <2.5
, vector >=0.10 && <0.13
exposed-modules:
Expand All @@ -67,7 +64,6 @@ library
NumHask.Array.Example
NumHask.Shape
default-language: Haskell2010

test-suite test
type:
exitcode-stdio-1.0
Expand Down
20 changes: 10 additions & 10 deletions numhask-array/src/NumHask/Array.hs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ instance
-- [43, 50]]
--
mmult :: forall c m n k a.
( Hilbert (Vector c k) a
( Hilbert (Vector c k a)
, Dimensions '[ m, k]
, Dimensions '[ k, n]
, Dimensions '[ m, n]
Expand Down Expand Up @@ -610,7 +610,6 @@ instance (Functor (Array c r), Foldable (Array c r), Additive (Array c r a), Nor
Normed (Array c r a) a where
normL1 r = foldr (+) zero $ normL1 <$> r
normL2 r = sqrt $ foldr (+) zero $ (** (one + one)) <$> r
normLp p r = (** (one / p)) $ foldr (+) zero $ (** p) . normL1 <$> r

instance (Eq (c a), Foldable (Array c r), Dimensions r, Container c, Epsilon a) =>
Epsilon (Array c r a) where
Expand All @@ -622,7 +621,6 @@ instance (Foldable (Array c r), Dimensions r, Container c, ExpField a, Subtracti
Metric (Array c r a) a where
distanceL1 a b = normL1 (a - b)
distanceL2 a b = normL2 (a - b)
distanceLp p a b = normLp p (a - b)

instance (Dimensions r, Container c, Integral a) => Integral (Array c r a) where
divMod a b = (d, m)
Expand All @@ -636,9 +634,7 @@ instance (Dimensions r, Container c, Integral a) => Integral (Array c r a) where
q = fmap fst x
r = fmap snd x

instance (Foldable (Array c r), CommutativeRing a, Semiring a, Dimensions r, Container c) =>
Hilbert (Array c r) a where
a <.> b = sum $ liftR2 (*) a b
type instance Actor (Array c r a) = a

instance (Dimensions r, Container c, Multiplicative a) =>
HadamardMultiplication (Array c r) a where
Expand All @@ -649,25 +645,29 @@ instance (Dimensions r, Container c, Divisive a) =>
(./.) = liftR2 (/)

instance (Dimensions r, Container c, Additive a) =>
AdditiveAction (Array c (r::[Nat])) a where
AdditiveAction (Array c (r::[Nat]) a) where
(.+) r s = fmap (s +) r
(+.) s = fmap (s +)

instance (Dimensions r, Container c, Subtractive a) =>
SubtractiveAction (Array c (r::[Nat])) a where
SubtractiveAction (Array c (r::[Nat]) a) where
(.-) r s = fmap (\x -> x - s) r
(-.) s = fmap (\x -> x - s)

instance (Dimensions r, Container c, Multiplicative a) =>
MultiplicativeAction (Array c (r :: [Nat])) a where
MultiplicativeAction (Array c (r :: [Nat]) a) where
(.*) r s = fmap (* s) r
(*.) s = fmap (s *)

instance (Dimensions r, Container c, Divisive a) =>
DivisiveAction (Array c (r::[Nat])) a where
DivisiveAction (Array c (r::[Nat]) a) where
(./) r s = fmap (/ s) r
(/.) s = fmap (/ s)

instance forall a c r. (Actor (Array c r a) ~ a, Foldable (Array c r), P.Distributive a, CommutativeRing a, Semiring a, Dimensions r, Container c) =>
Hilbert (Array c r a) where
a <.> b = sum $ liftR2 (*) a b

instance
( Foldable (Array c r)
, Dimensions r
Expand Down
11 changes: 0 additions & 11 deletions numhask-array/stack.yaml

This file was deleted.

11 changes: 4 additions & 7 deletions numhask-bench/numhask-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ build-type:
Simple
cabal-version:
>= 1.18

extra-source-files:
stack.yaml

source-repository head
type:
git
location:
https://github.com/tonyday567/numhask-bench

https://github.com/tonyday567/numhask
subdir:
numhask-array
executable numhask-bench
main-is:
bench.hs
Expand All @@ -52,7 +49,7 @@ executable numhask-bench
-Wincomplete-uni-patterns
-Wredundant-constraints
build-depends:
base >=4.7 && <5
base >=4.7 && <4.13
, hmatrix
, matrix
, numhask
Expand Down
17 changes: 0 additions & 17 deletions numhask-bench/stack.yaml

This file was deleted.

Loading