validity 0.9.0.0 → 0.9.0.1
raw patch · 2 files changed
+13/−5 lines, 2 files
Files
- src/Data/Validity.hs +8/−1
- validity.cabal +5/−4
src/Data/Validity.hs view
@@ -461,12 +461,19 @@ #endif -- | Valid if the contained numbers are valid and the denominator is -- strictly positive.-instance (Num a, Ord a, Validity a) => Validity (Ratio a) where+instance (Validity a, Ord a, Num a, Integral a) => Validity (Ratio a) where validate (n :% d) = mconcat [ annotate n "The numerator" , annotate d "The denominator" , declare "The denominator is strictly positive." $ d > 0+ , declare "The ratio is normalised" $+ case d of+ 0 -> False+ _ ->+ let g = gcd n d+ n' :% d' = (n `quot` g) :% (d `quot` g)+ in n' :% d' == n :% d ] -- | Valid according to the contained 'Integer'.
validity.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.28.2.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.1. -- -- see: https://github.com/sol/hpack ----- hash: d7dbe113de14753bb19dacab5a6fad8e6ac1fd75f7d6157d10c29c478a6b267f+-- hash: ea622d10d177b4be018cdfc126d397fdf597d052e886eb69bc3a7d334f8bcfca name: validity-version: 0.9.0.0+version: 0.9.0.1 synopsis: Validity typeclass description: For more info, see <https://github.com/NorfairKing/validity the readme>. .@@ -40,7 +42,6 @@ license: MIT license-file: LICENSE build-type: Simple-cabal-version: >= 1.10 source-repository head type: git