packages feed

numhask-range 0.1.1 → 0.1.2

raw patch · 8 files changed

+153/−136 lines, 8 filesdep ~numhaskPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: numhask

API changes (from Hackage documentation)

+ NumHask.Pair: instance NumHask.Algebra.Additive.Additive a => NumHask.Algebra.Basis.AdditiveBasis NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Additive.Additive a => NumHask.Algebra.Module.AdditiveModule NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Additive.AdditiveGroup a => NumHask.Algebra.Basis.AdditiveGroupBasis NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Additive.AdditiveGroup a => NumHask.Algebra.Module.AdditiveGroupModule NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Multiplicative.Multiplicative a => NumHask.Algebra.Basis.MultiplicativeBasis NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Multiplicative.Multiplicative a => NumHask.Algebra.Module.MultiplicativeModule NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Multiplicative.MultiplicativeGroup a => NumHask.Algebra.Basis.MultiplicativeGroupBasis NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Multiplicative.MultiplicativeGroup a => NumHask.Algebra.Module.MultiplicativeGroupModule NumHask.Pair.Pair a
+ NumHask.Pair: instance NumHask.Algebra.Singleton.Singleton NumHask.Pair.Pair
+ NumHask.Range: instance NumHask.Algebra.Additive.Additive a => NumHask.Algebra.Basis.AdditiveBasis NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Additive.Additive a => NumHask.Algebra.Module.AdditiveModule NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Additive.AdditiveGroup a => NumHask.Algebra.Basis.AdditiveGroupBasis NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Additive.AdditiveGroup a => NumHask.Algebra.Module.AdditiveGroupModule NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Multiplicative.Multiplicative a => NumHask.Algebra.Basis.MultiplicativeBasis NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Multiplicative.Multiplicative a => NumHask.Algebra.Module.MultiplicativeModule NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Multiplicative.MultiplicativeGroup a => NumHask.Algebra.Basis.MultiplicativeGroupBasis NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Multiplicative.MultiplicativeGroup a => NumHask.Algebra.Module.MultiplicativeGroupModule NumHask.Range.Range a
+ NumHask.Range: instance NumHask.Algebra.Singleton.Singleton NumHask.Range.Range
+ NumHask.Rect: instance NumHask.Algebra.Additive.Additive a => NumHask.Algebra.Basis.AdditiveBasis NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Additive.Additive a => NumHask.Algebra.Module.AdditiveModule NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Additive.AdditiveGroup a => NumHask.Algebra.Basis.AdditiveGroupBasis NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Additive.AdditiveGroup a => NumHask.Algebra.Module.AdditiveGroupModule NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Multiplicative.Multiplicative a => NumHask.Algebra.Basis.MultiplicativeBasis NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Multiplicative.Multiplicative a => NumHask.Algebra.Module.MultiplicativeModule NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Multiplicative.MultiplicativeGroup a => NumHask.Algebra.Basis.MultiplicativeGroupBasis NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Multiplicative.MultiplicativeGroup a => NumHask.Algebra.Module.MultiplicativeGroupModule NumHask.Rect.Rect a
+ NumHask.Rect: instance NumHask.Algebra.Singleton.Singleton NumHask.Rect.Rect

Files

numhask-range.cabal view
@@ -1,94 +1,62 @@-name: numhask-range-version: 0.1.1-synopsis:-  Numbers that are range representations-description:-  Numbers that represent ranges of all sorts.-category:-  project-homepage:-  https://github.com/tonyday567/numhask-range-license:-  BSD3-license-file:-  LICENSE-author:-  Tony Day-maintainer:-  tonyday567@gmail.com-copyright:-  Tony Day-build-type:-  Simple-cabal-version:-  >=1.18+-- This file has been generated from package.yaml by hpack version 0.18.1.+--+-- see: https://github.com/sol/hpack++name:           numhask-range+version:        0.1.2+synopsis:       Numbers that are range representations+description:    Numbers that represent ranges of all sorts.+category:       project+homepage:       https://github.com/tonyday567/numhask-range#readme+bug-reports:    https://github.com/tonyday567/numhask-range/issues+license:        BSD3+license-file:   LICENSE+author:         Tony Day+maintainer:     tonyday567@gmail.com+copyright:      Tony Day+build-type:     Simple+cabal-version:  >= 1.10+ extra-source-files:-  readme.md,-  stack.yaml,-  other/*.svg-extra-doc-files:-  other/*.svg+  readme.md+  stack.yaml++source-repository head+  type: git+  location: https://github.com/tonyday567/numhask-range+ library-  default-language:-    Haskell2010-  ghc-options:+  default-language: Haskell2010   hs-source-dirs:     src   exposed-modules:-    NumHask.Space,-    NumHask.Range,-    NumHask.Rect,+    NumHask.Space+    NumHask.Range+    NumHask.Rect     NumHask.Pair+  other-modules:+    Paths_numhask_range   build-depends:-    base >= 4.7 && < 4.11,-    numhask >= 0.0.9,-    protolude >= 0.1.8 && < 0.3,-    QuickCheck >= 2.8 && < 3,-    adjunctions >= 4.3 && < 5,-    distributive >= 0.5 && < 0.6,-    semigroupoids >= 5.1 && < 6-  default-extensions:-    DeriveGeneric,-    DeriveTraversable,-    FlexibleContexts,-    InstanceSigs,-    MultiParamTypeClasses,-    NoImplicitPrelude,-    OverloadedStrings,-    PatternSynonyms,-    TypeFamilies,-    UnicodeSyntax+    numhask >=0.1.3,+    base >=4.7 && <4.11,+    protolude >=0.1.8 && <0.3,+    QuickCheck >=2.8 && <3,+    adjunctions >=4.3 && <5,+    distributive >=0.5 && <0.6,+    semigroupoids >=5.1 && <6+  default-extensions: DeriveGeneric DeriveTraversable FlexibleContexts InstanceSigs MultiParamTypeClasses NegativeLiterals NoImplicitPrelude OverloadedStrings PatternSynonyms TypeFamilies UnicodeSyntax  test-suite test-  default-language:-    Haskell2010-  type:-    exitcode-stdio-1.0+  default-language: Haskell2010+  type: exitcode-stdio-1.0   hs-source-dirs:     test-  main-is:-    test.hs+  main-is: test.hs   build-depends:-    base >= 4.7 && < 5,+    numhask >=0.1.3,+    base >=4.7 && <5,     doctest,-    numhask >= 0.0.9,     numhask-range,     tasty,     tasty-quickcheck-  default-extensions:-    DeriveGeneric,-    DeriveTraversable,-    FlexibleContexts,-    InstanceSigs,-    MultiParamTypeClasses,-    NoImplicitPrelude,-    OverloadedStrings,-    PatternSynonyms,-    TypeFamilies,-    UnicodeSyntax--source-repository head-  type:-    git-  location:-    https://github.com/tonyday567/numhask-range+  default-extensions: DeriveGeneric DeriveTraversable FlexibleContexts InstanceSigs MultiParamTypeClasses NegativeLiterals NoImplicitPrelude OverloadedStrings PatternSynonyms TypeFamilies UnicodeSyntax
− other/unitSquare.svg
@@ -1,1 +0,0 @@-<svg xmlns="http://www.w3.org/2000/svg" height="100.0000" stroke-opacity="1" viewBox="0 0 100 100" font-size="1" width="100.0000" xmlns:xlink="http://www.w3.org/1999/xlink" stroke="rgb(0,0,0)" version="1.1"><defs></defs><g stroke-linejoin="miter" stroke-opacity="1.0" fill-opacity="0.0" stroke="rgb(0,0,0)" stroke-width="0.5" fill="rgb(0,0,0)" stroke-linecap="butt" stroke-miterlimit="10.0"><path d="M 95.4545,95.4545 l -0.0000,-90.9091 h -90.9091 l -0.0000,90.9091 Z"/></g><g stroke-linejoin="miter" stroke-opacity="1.0" fill-opacity="1.0" stroke="rgb(0,0,0)" stroke-width="0.0" fill="rgb(255,0,0)" stroke-linecap="butt" stroke-miterlimit="10.0"><path d="M 52.0000,50.0000 c 0.0000,-1.1046 -0.8954,-2.0000 -2.0000 -2.0000c -1.1046,-0.0000 -2.0000,0.8954 -2.0000 2.0000c -0.0000,1.1046 0.8954,2.0000 2.0000 2.0000c 1.1046,0.0000 2.0000,-0.8954 2.0000 -2.0000Z"/></g></svg>
readme.md view
@@ -10,11 +10,11 @@  This library emerged as a bridge between `chart-unit`, an effort to create a clean, minimalist chart api, and `numhask`, an effort to create clean, minimalist numerical classes. -If you ask yourself what a chart is, sifting through the cruft of accumulated practice, nomenclature and usage, digging deep for charting's essence, and if you ask the question in haskell, here's what you find:+If you ask yourself what a chart is, sifting through the cruft of accumulated practice, nomenclature and usage, digging deep for charting's essence, and if you ask the question in haskell, here's the simplest object you find: -![other/unitSquare.svg](other/unitSquare.svg)+[![unitSquare](https://tonyday567.github.io/other/unitSquare.svg)](https://tonyday567.github.io/other/unitSquare.svg) -To a first approximation, charting is transforming unit squares and placing them on a physical XY plane, such as a screen, or on graph paper.  A rectangle is a distended square; a line is a very thin rectangle; a histogram is a series of rectangles, and axes are nothing more than a collection of squares. The main thing on a chart that isn't a square is text, but even then we use square pixels to render.+To a first approximation, charting is transforming and placing this unit on a physical XY plane, such as a screen, or on graph paper.  A rectangle is a distended square; a line is a very thin rectangle; a histogram is a series of rectangles, and axes are nothing more than a collection of squares. The main thing on a chart that isn't a square is text, but even then we use square pixels to render.  one ---
src/NumHask/Pair.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NoImplicitPrelude #-}@@ -18,18 +19,19 @@   , pattern Pair   ) where -import NumHask.Prelude-import Text.Show- import Data.Distributive import Data.Functor.Apply (Apply(..)) import Data.Functor.Classes+import Data.Functor.Rep import Data.Semigroup.Foldable (Foldable1(..)) import Data.Semigroup.Traversable (Traversable1(..))+import NumHask.Prelude import Test.QuickCheck.Arbitrary (Arbitrary(..))+import Text.Show  -- $setup -- >>> :set -XNoImplicitPrelude+-- >>> :set -XFlexibleContexts --  -- | A pair of a's, implemented as a tuple, but api represented as a Pair of a's.@@ -220,3 +222,29 @@  instance (BoundedField a) => BoundedField (Pair a) where   isNaN (Pair a b) = isNaN a || isNaN b++instance (Additive a) => AdditiveBasis Pair a where+    (.+.) = liftR2 (+)+instance (AdditiveGroup a) => AdditiveGroupBasis Pair a where+    (.-.) = liftR2 (-)+instance (Multiplicative a) => MultiplicativeBasis Pair a where+    (.*.) = liftR2 (*)+instance (MultiplicativeGroup a) => MultiplicativeGroupBasis Pair a where+    (./.) = liftR2 (/)++instance (Additive a) => AdditiveModule Pair a where+    (.+) r s = fmap (s+) r+    (+.) s r = fmap (s+) r+instance (AdditiveGroup a) => AdditiveGroupModule Pair a where+    (.-) r s = fmap (\x -> x - s) r+    (-.) s r = fmap (\x -> x - s) r+instance (Multiplicative a) => MultiplicativeModule Pair a where+    (.*) r s = fmap (s*) r+    (*.) s r = fmap (s*) r+instance (MultiplicativeGroup a) => MultiplicativeGroupModule Pair a where+    (./) r s = fmap (/ s) r+    (/.) s r = fmap (/ s) r++instance Singleton Pair where+    singleton a = Pair a a+
src/NumHask/Range.hs view
@@ -21,13 +21,14 @@   , gridSensible  ) where -import NumHask.Prelude hiding (singleton)+import NumHask.Prelude as P import NumHask.Space  import Data.Functor.Apply (Apply(..)) import Data.Semigroup.Foldable (Foldable1(..)) import Data.Semigroup.Traversable (Traversable1(..)) import Data.Functor.Classes+import Data.Functor.Rep import Data.Distributive import Test.QuickCheck.Arbitrary (Arbitrary(..)) import qualified Text.Show as Show@@ -59,7 +60,7 @@ -- Range 0.0 1.0 -- >>> Range 0 1 / one -- Range 0.0 1.0--- >>> singleton 2.3 :: Range Double+-- >>> P.singleton 2.3 :: Range Double -- Range 2.3 2.3 -- >>> abs (Range 1 0) -- Range 0.0 1.0@@ -215,7 +216,11 @@ theta :: (AdditiveUnital a) => Range a theta = Range zero zero -instance (FromInteger a, Ord a, BoundedField a) => Space (Range a) where+instance+    ( FromInteger a+    , Ord a+    , BoundedField a) =>+    Space (Range a) where     type Element (Range a) = a     union (Range l0 u0) (Range l1 u1) = Range (min l0 l1) (max u0 u1)     nul = Range infinity neginfinity@@ -268,3 +273,27 @@                 UpperPos -> (1,n')                 MidPos -> (0,n' - 1) +instance (Additive a) => AdditiveBasis Range a where+    (.+.) = liftR2 (+)+instance (AdditiveGroup a) => AdditiveGroupBasis Range a where+    (.-.) = liftR2 (-)+instance (Multiplicative a) => MultiplicativeBasis Range a where+    (.*.) = liftR2 (*)+instance (MultiplicativeGroup a) => MultiplicativeGroupBasis Range a where+    (./.) = liftR2 (/)++instance (Additive a) => AdditiveModule Range a where+    (.+) r s = fmap (s+) r+    (+.) s r = fmap (s+) r+instance (AdditiveGroup a) => AdditiveGroupModule Range a where+    (.-) r s = fmap (\x -> x - s) r+    (-.) s r = fmap (\x -> x - s) r+instance (Multiplicative a) => MultiplicativeModule Range a where+    (.*) r s = fmap (s*) r+    (*.) s r = fmap (s*) r+instance (MultiplicativeGroup a) => MultiplicativeGroupModule Range a where+    (./) r s = fmap (/ s) r+    (/.) s r = fmap (/ s) r++instance Singleton Range where+    singleton a = Range a a
src/NumHask/Rect.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NoImplicitPrelude #-}@@ -24,10 +25,11 @@ import Data.Distributive import Data.Functor.Apply (Apply(..)) import Data.Functor.Compose+import Data.Functor.Rep import Data.Semigroup.Foldable (Foldable1(..)) import Data.Semigroup.Traversable (Traversable1(..)) import NumHask.Pair-import NumHask.Prelude hiding ((<.>), singleton)+import NumHask.Prelude hiding ((<.>)) import NumHask.Range import NumHask.Space import qualified Text.Show as Show@@ -243,3 +245,31 @@   where     (Pair a' c') = project r0 r1 (Pair a c)     (Pair b' d') = project r0 r1 (Pair b d)++instance (Additive a) => AdditiveBasis Rect a where+    (.+.) = liftR2 (+)+instance (AdditiveGroup a) => AdditiveGroupBasis Rect a where+    (.-.) = liftR2 (-)+instance (Multiplicative a) => MultiplicativeBasis Rect a where+    (.*.) = liftR2 (*)+instance (MultiplicativeGroup a) => MultiplicativeGroupBasis Rect a where+    (./.) = liftR2 (/)++instance (Additive a) => AdditiveModule Rect a where+    (.+) r s = fmap (s+) r+    (+.) s r = fmap (s+) r+instance (AdditiveGroup a) => AdditiveGroupModule Rect a where+    (.-) r s = fmap (\x -> x - s) r+    (-.) s r = fmap (\x -> x - s) r+instance (Multiplicative a) => MultiplicativeModule Rect a where+    (.*) r s = fmap (s*) r+    (*.) s r = fmap (s*) r+instance (MultiplicativeGroup a) => MultiplicativeGroupModule Rect a where+    (./) r s = fmap (/ s) r+    (/.) s r = fmap (/ s) r++-- | fixme: this is a deeply flawed hack+instance Singleton Rect where+    singleton a = Rect a a a a++
stack.yaml view
@@ -1,6 +1,9 @@-resolver: lts-8.24+resolver: nightly-2017-11-07  packages:   - '.'+ extra-deps:-  - numhask-0.1.2+  #- git: https://github.com/tonyday567/numhask.git+  #  commit: c7300b5f2a56554f3948d7c5aacb7ac8ed924e31+  - numhask-0.1.3
test/test.hs view
@@ -11,58 +11,18 @@ import NumHask.Range import NumHask.Rect import NumHask.Space+import NumHask.Laws  import Test.DocTest import Test.Tasty (TestName, TestTree, defaultMain, testGroup) import Test.Tasty.QuickCheck -data LawArity a-  = Nonary Bool-  | Unary (a -> Bool)-  | Binary (a -> a -> Bool)-  | Ternary (a -> a -> a -> Bool)-  | Ornary (a -> a -> a -> a -> Bool)-  | Failiary (a -> Property)--data LawArity2 a b-  = Unary2 (a -> Bool)-  | Binary2 (a -> b -> Bool)-  | Ternary2 (a -> a -> b -> Bool)-  | Ternary2' (a -> b -> b -> Bool)-  | Ternary2'' (a -> a -> a -> Bool)-  | Quad31 (a -> a -> a -> b -> Bool)-  | Quad22 (a -> a -> b -> b -> Bool)-  | Failiary2 (a -> Property)--type Law a = (TestName, LawArity a)--type Law2 a b = (TestName, LawArity2 a b)--testLawOf :: (Arbitrary a, Show a) => [a] -> Law a -> TestTree-testLawOf _ (name, Nonary f) = testProperty name f-testLawOf _ (name, Unary f) = testProperty name f-testLawOf _ (name, Binary f) = testProperty name f-testLawOf _ (name, Ternary f) = testProperty name f-testLawOf _ (name, Ornary f) = testProperty name f-testLawOf _ (name, Failiary f) = testProperty name f--testLawOf2 ::-     (Arbitrary a, Show a, Arbitrary b, Show b)-  => [(a, b)]-  -> Law2 a b-  -> TestTree-testLawOf2 _ (name, Unary2 f) = testProperty name f-testLawOf2 _ (name, Binary2 f) = testProperty name f-testLawOf2 _ (name, Ternary2 f) = testProperty name f-testLawOf2 _ (name, Ternary2' f) = testProperty name f-testLawOf2 _ (name, Ternary2'' f) = testProperty name f-testLawOf2 _ (name, Quad22 f) = testProperty name f-testLawOf2 _ (name, Quad31 f) = testProperty name f-testLawOf2 _ (name, Failiary2 f) = testProperty name f- main :: IO () main = do-  doctest ["src/NumHask/Range.hs", "src/NumHask/Rect.hs", "src/NumHask/Pair.hs"]+  doctest+      [ "src/NumHask/Pair.hs"+      , "src/NumHask/Range.hs"+      ]   defaultMain $     testGroup       "numhask-range"