packages feed

probability 0.2.5.2 → 0.2.6

raw patch · 6 files changed

+101/−40 lines, 6 filesdep ~randomPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: random

API changes (from Hackage documentation)

+ Numeric.Probability.Simulation: infix 6 ~.
+ Numeric.Probability.Simulation: infix 8 ~*.
- Numeric.Probability.Distribution: (>>=?) :: (Fractional prob) => T prob a -> (a -> Bool) -> T prob a
+ Numeric.Probability.Distribution: (>>=?) :: Fractional prob => T prob a -> (a -> Bool) -> T prob a
- Numeric.Probability.Distribution: (?=<<) :: (Fractional prob) => (a -> Bool) -> T prob a -> T prob a
+ Numeric.Probability.Distribution: (?=<<) :: Fractional prob => (a -> Bool) -> T prob a -> T prob a
- Numeric.Probability.Distribution: cond :: (Num prob) => T prob Bool -> T prob a -> T prob a -> T prob a
+ Numeric.Probability.Distribution: cond :: Num prob => T prob Bool -> T prob a -> T prob a -> T prob a
- Numeric.Probability.Distribution: expected :: (Num a) => T a a -> a
+ Numeric.Probability.Distribution: expected :: Num a => T a a -> a
- Numeric.Probability.Distribution: filter :: (Fractional prob) => (a -> Bool) -> T prob a -> T prob a
+ Numeric.Probability.Distribution: filter :: Fractional prob => (a -> Bool) -> T prob a -> T prob a
- Numeric.Probability.Distribution: fromFreqs :: (Fractional prob) => [(a, prob)] -> T prob a
+ Numeric.Probability.Distribution: fromFreqs :: Fractional prob => [(a, prob)] -> T prob a
- Numeric.Probability.Distribution: lift :: (Num prob) => ([(a, prob)] -> [(a, prob)]) -> T prob a -> T prob a
+ Numeric.Probability.Distribution: lift :: Num prob => ([(a, prob)] -> [(a, prob)]) -> T prob a -> T prob a
- Numeric.Probability.Distribution: mapMaybe :: (Fractional prob) => (a -> Maybe b) -> T prob a -> T prob b
+ Numeric.Probability.Distribution: mapMaybe :: Fractional prob => (a -> Maybe b) -> T prob a -> T prob b
- Numeric.Probability.Distribution: stdDev :: (Floating a) => T a a -> a
+ Numeric.Probability.Distribution: stdDev :: Floating a => T a a -> a
- Numeric.Probability.Distribution: truth :: (Num prob) => T prob Bool -> prob
+ Numeric.Probability.Distribution: truth :: Num prob => T prob Bool -> prob
- Numeric.Probability.Distribution: variance :: (Num a) => T a a -> a
+ Numeric.Probability.Distribution: variance :: Num a => T a a -> a
- Numeric.Probability.Example.Barber: barberSystem :: (Ord b) => (System () -> b) -> RDist b
+ Numeric.Probability.Example.Barber: barberSystem :: Ord b => (System () -> b) -> RDist b
- Numeric.Probability.Example.Collection: draw :: (Fractional prob) => ([Card], Collection Card) -> T prob ([Card], Collection Card)
+ Numeric.Probability.Example.Collection: draw :: Fractional prob => ([Card], Collection Card) -> T prob ([Card], Collection Card)
- Numeric.Probability.Example.Collection: select :: (Fractional prob) => Int -> Collection a -> T prob [a]
+ Numeric.Probability.Example.Collection: select :: Fractional prob => Int -> Collection a -> T prob [a]
- Numeric.Probability.Example.Collection: select1 :: (Fractional prob) => Collection a -> T prob a
+ Numeric.Probability.Example.Collection: select1 :: Fractional prob => Collection a -> T prob a
- Numeric.Probability.Example.Collection: select2 :: (Fractional prob) => Collection a -> T prob (a, a)
+ Numeric.Probability.Example.Collection: select2 :: Fractional prob => Collection a -> T prob (a, a)
- Numeric.Probability.Example.Collection: selectOne :: (Fractional prob) => StateT (Collection a) (T prob) a
+ Numeric.Probability.Example.Collection: selectOne :: Fractional prob => StateT (Collection a) (T prob) a
- Numeric.Probability.Example.Kruskal: compareMaybe :: (Ord a) => Maybe a -> Maybe a -> Ordering
+ Numeric.Probability.Example.Kruskal: compareMaybe :: Ord a => Maybe a -> Maybe a -> Ordering
- Numeric.Probability.Example.Kruskal: cumulate :: (Ord a) => Dist (Maybe a) -> [(Maybe a, Probability)]
+ Numeric.Probability.Example.Kruskal: cumulate :: Ord a => Dist (Maybe a) -> [(Maybe a, Probability)]
- Numeric.Probability.Percentage: roundRel :: (RealFrac a) => Int -> a -> a
+ Numeric.Probability.Percentage: roundRel :: RealFrac a => Int -> a -> a
- Numeric.Probability.Transition: apply :: (Num prob) => Change a -> T prob a
+ Numeric.Probability.Transition: apply :: Num prob => Change a -> T prob a
- Numeric.Probability.Transition: enum :: (RealFloat prob) => [Int] -> SpreadC prob a
+ Numeric.Probability.Transition: enum :: RealFloat prob => [Int] -> SpreadC prob a
- Numeric.Probability.Transition: fix :: (Num prob, Ord a, Ord b) => ((a -> EitherT a (T prob) b) -> (a -> EitherT a (T prob) b)) -> T prob a -> T prob b
+ Numeric.Probability.Transition: fix :: (Num prob, Ord a, Ord b) => ((a -> EitherT a (T prob) b) -> a -> EitherT a (T prob) b) -> T prob a -> T prob b
- Numeric.Probability.Transition: id :: (Num prob) => T prob a
+ Numeric.Probability.Transition: id :: Num prob => T prob a
- Numeric.Probability.Transition: linear :: (Fractional prob) => SpreadC prob a
+ Numeric.Probability.Transition: linear :: Fractional prob => SpreadC prob a
- Numeric.Probability.Transition: maybe :: (Num prob) => prob -> Change a -> T prob a
+ Numeric.Probability.Transition: maybe :: Num prob => prob -> Change a -> T prob a
- Numeric.Probability.Transition: normal :: (Floating prob) => SpreadC prob a
+ Numeric.Probability.Transition: normal :: Floating prob => SpreadC prob a
- Numeric.Probability.Transition: relative :: (RealFloat prob) => [prob] -> SpreadC prob a
+ Numeric.Probability.Transition: relative :: RealFloat prob => [prob] -> SpreadC prob a
- Numeric.Probability.Transition: uniform :: (Fractional prob) => SpreadC prob a
+ Numeric.Probability.Transition: uniform :: Fractional prob => SpreadC prob a

Files

+ Changes.md view
@@ -0,0 +1,17 @@+# Change log for the `probability` package++## 0.2.6++ * `instance Monad Distribution.T`:+   Remove definition of `fail`.+   This turns calls to `fail` into `error`s+   for GHCs prior to the "Monad Fail Proposal".+   Formerly it was an empty list,+   but this was bad since the probabilities in an empty list+   sum up to zero not one, thus breaking the invariant.+   Beginning with GHC-8.8 and the "Monad Fail Proposal"+   you can no longer accidentally call `fail`,+   since `Distribution.T` is not an instance of `MonadFail`.++ * `instance Monad Probability.EitherT`:+   Define `MonadFail` instance for GHC>=8.8.1.
probability.cabal view
@@ -1,5 +1,5 @@ Name:               probability-Version:            0.2.5.2+Version:            0.2.6 License:            BSD3 License-File:       COPYRIGHT Author:             Martin Erwig <erwig@eecs.oregonstate.edu>, Steve Kollmansberger@@ -17,6 +17,8 @@ Tested-With:    GHC==7.0.2, GHC==7.2.2, GHC==7.4.2, GHC==7.8.2 Cabal-Version:  >=1.6 Build-Type:     Simple+Extra-Source-Files:+  Changes.md Data-Files:   README   ToDo@@ -28,7 +30,7 @@ Source-Repository this   type:     darcs   location: http://code.haskell.org/~thielema/probability/-  tag:      0.2.5.2+  tag:      0.2.6   Flag splitBase@@ -43,6 +45,10 @@       containers >=0.1 && <0.7,       random >=1.0 && <2,       base >=2 && <5+    If impl(ghc>=8.8)+      Hs-Source-Dirs: src-fail/from-4.13/+    Else+      Hs-Source-Dirs: src-fail/before-4.13/   Else     Build-Depends:       special-functors >=1.0 && <1.1,
+ src-fail/before-4.13/Numeric/Probability/Either.hs view
@@ -0,0 +1,37 @@+module Numeric.Probability.Either where++import Control.Monad.Instances ()++import Control.Applicative (Applicative, pure, (<*>), liftA2, )+++newtype EitherT a m b = EitherT (m (Either a b))++instance Functor m => Functor (EitherT a m) where+   fmap f (EitherT m) = EitherT $ fmap (fmap f) m++instance Applicative m => Applicative (EitherT a m) where+   pure a = EitherT $ pure $ Right a+   EitherT af <*> EitherT am =+      EitherT $+      liftA2 (\ef em ->+         case ef of+            Left b -> Left b+            Right f ->+               case em of+                  Left b -> Left b+                  Right m -> Right $ f m) af am++instance Monad m => Monad (EitherT a m) where+   return a = EitherT $ return $ Right a+   EitherT m >>= f  =  EitherT $ do+      e <- m+      case e of+         Left b -> return $ Left b+         Right a ->+            case f a of+               EitherT n -> n+   fail s = EitherT $ fail s++throw :: Applicative m => a -> EitherT a m b+throw a = EitherT $ pure $ Left a
+ src-fail/from-4.13/Numeric/Probability/Either.hs view
@@ -0,0 +1,39 @@+module Numeric.Probability.Either where++import Control.Monad.Instances ()++import Control.Applicative (Applicative, pure, (<*>), liftA2, )+++newtype EitherT a m b = EitherT (m (Either a b))++instance Functor m => Functor (EitherT a m) where+   fmap f (EitherT m) = EitherT $ fmap (fmap f) m++instance Applicative m => Applicative (EitherT a m) where+   pure a = EitherT $ pure $ Right a+   EitherT af <*> EitherT am =+      EitherT $+      liftA2 (\ef em ->+         case ef of+            Left b -> Left b+            Right f ->+               case em of+                  Left b -> Left b+                  Right m -> Right $ f m) af am++instance Monad m => Monad (EitherT a m) where+   return a = EitherT $ return $ Right a+   EitherT m >>= f  =  EitherT $ do+      e <- m+      case e of+         Left b -> return $ Left b+         Right a ->+            case f a of+               EitherT n -> n++instance MonadFail m => MonadFail (EitherT a m) where+   fail s = EitherT $ fail s++throw :: Applicative m => a -> EitherT a m b+throw a = EitherT $ pure $ Left a
src/Numeric/Probability/Distribution.hs view
@@ -64,7 +64,6 @@ instance Num prob => Monad (T prob) where   return   = certainly   d >>= f  = Cons [(y,q*p) | (x,p) <- decons d, (y,q) <- decons (f x)]-  fail _   = Cons []  instance Num prob => Applicative (T prob) where   pure     = certainly
− src/Numeric/Probability/Either.hs
@@ -1,37 +0,0 @@-module Numeric.Probability.Either where--import Control.Monad.Instances ()--import Control.Applicative (Applicative, pure, (<*>), liftA2, )---newtype EitherT a m b = EitherT (m (Either a b))--instance Functor m => Functor (EitherT a m) where-   fmap f (EitherT m) = EitherT $ fmap (fmap f) m--instance Applicative m => Applicative (EitherT a m) where-   pure a = EitherT $ pure $ Right a-   EitherT af <*> EitherT am =-      EitherT $-      liftA2 (\ef em ->-         case ef of-            Left b -> Left b-            Right f ->-               case em of-                  Left b -> Left b-                  Right m -> Right $ f m) af am--instance Monad m => Monad (EitherT a m) where-   return a = EitherT $ return $ Right a-   EitherT m >>= f  =  EitherT $ do-      e <- m-      case e of-         Left b -> return $ Left b-         Right a ->-            case f a of-               EitherT n -> n-   fail s = EitherT $ fail s--throw :: Applicative m => a -> EitherT a m b-throw a = EitherT $ pure $ Left a