summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitryDzhus <>2019-06-11 09:16:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-06-11 09:16:00 (GMT)
commit72146e424a3d1dcaa74faadfe2b77a12b41768e2 (patch)
treec39cef53895c60ccf0aebdb677abb136fdf62244
parent31c5451f597cecf43599078dd8a1277164d66845 (diff)
version 0.50.5
-rw-r--r--CHANGELOG.md12
-rw-r--r--simple-vec3.cabal4
-rw-r--r--src/Data/Vec3/Class.hs6
-rw-r--r--tests/Main.hs4
4 files changed, 20 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f302626..177752e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,15 @@
# Changelog
-## [0.4.0.10] - 2018-01-18
+## [0.5] - 2019-06-11
+
+### Changed
+
+- Operator precedence order is now as follows: `.^`, `.*`, `<+>`,
+ `<->`, `><` (multiplication binds most tightly).
+
+- Test suite dependencies bump
+
+## [0.4.0.10] - 2019-01-18
### Changed
@@ -118,6 +127,7 @@
## [0.1.0.0] - 2012-12-05
+[0.5]: https://github.com/dzhus/simple-vec3/compare/0.4.0.10...0.5
[0.4.0.10]:https://github.com/dzhus/simple-vec3/compare/0.4.0.9...0.4.0.10
[0.4.0.9]: https://github.com/dzhus/simple-vec3/compare/0.4.0.8...0.4.0.9
[0.4.0.8]: https://github.com/dzhus/simple-vec3/compare/0.4.0.7...0.4.0.8
diff --git a/simple-vec3.cabal b/simple-vec3.cabal
index 5d2f994..e77d2e0 100644
--- a/simple-vec3.cabal
+++ b/simple-vec3.cabal
@@ -1,6 +1,6 @@
cabal-version: 1.12
name: simple-vec3
-version: 0.4.0.10
+version: 0.5
license: BSD3
license-file: LICENSE
maintainer: dima@dzhus.org
@@ -30,7 +30,7 @@ library
default-language: Haskell2010
ghc-options: -Wall -Wcompat -O2
build-depends:
- QuickCheck <2.13,
+ QuickCheck <2.14,
base <5,
vector <0.13
diff --git a/src/Data/Vec3/Class.hs b/src/Data/Vec3/Class.hs
index 4ac34b1..61c6527 100644
--- a/src/Data/Vec3/Class.hs
+++ b/src/Data/Vec3/Class.hs
@@ -1,7 +1,6 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE TypeSynonymInstances #-}
module Data.Vec3.Class
( Vec3(..)
@@ -42,11 +41,13 @@ class Vec3 v where
(<+>) :: v -> v -> v
(<+>) = zipWith (+)
{-# INLINE (<+>) #-}
+ infixl 5 <+>
-- | Subtract two vectors.
(<->) :: v -> v -> v
(<->) = zipWith (-)
{-# INLINE (<->) #-}
+ infixl 5 <->
-- | Cross product.
(><) :: v -> v -> v
@@ -56,18 +57,21 @@ class Vec3 v where
where
(x1, y1, z1) = toXYZ v1
(x2, y2, z2) = toXYZ v2
+ infixl 6 ><
-- | Scale a vector.
(.^) :: v -> Double -> v
(.^) v s = fromXYZ (x * s, y * s, z * s)
where
(x, y, z) = toXYZ v
+ infixl 7 .^
-- | Dot product.
(.*) :: v -> v -> Double
(.*) v1 v2 = x + y + z
where
(x, y, z) = toXYZ $ zipWith (*) v1 v2
+ infixl 6 .*
-- | Euclidean norm of a vector.
norm :: v -> Double
diff --git a/tests/Main.hs b/tests/Main.hs
index 488aea0..1b5afb9 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -58,10 +58,10 @@ tests _ =
(\(v :: ty) -> v .^ 1 <~=> v)
, testProperty
"Distributivity wrt vector addition"
- (\(a :: ty) b p -> ((a <+> b) .^ p) <~=> (a .^ p) <+> (b .^ p))
+ (\(a :: ty) b p -> ((a <+> b) .^ p) <~=> a .^ p <+> b .^ p)
, testProperty
"Distributivity wrt scalar addition"
- (\(a :: ty) p q -> a .^ (p + q) <~=> (a .^ p) <+> (a .^ q))
+ (\(a :: ty) p q -> a .^ (p + q) <~=> a .^ p <+> a .^ q)
, testProperty
"Subtraction definition"
(\(a :: ty) b -> a <+> invert b <~=> a <-> b)