Skip to content

Commit

Permalink
Merge pull request #255 from turion/dev_warnings_as_errors
Browse files Browse the repository at this point in the history
Warnings as errors
  • Loading branch information
turion authored Feb 10, 2023
2 parents 06d87a1 + d4ce1c9 commit a4d0c92
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ jobs:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build
run: nix --print-build-logs build .#packages.${{ matrix.system }}.monad-bayes
- name: Development environenment
- name: Development environment
run: nix --print-build-logs develop .#packages.${{ matrix.system }}.monad-bayes --command echo Ready
3 changes: 1 addition & 2 deletions benchmark/Speed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Main (main) where

import Control.Monad.Bayes.Class (MonadDistribution, MonadMeasure)
import Control.Monad.Bayes.Class (MonadMeasure)
import Control.Monad.Bayes.Inference.MCMC (MCMCConfig (MCMCConfig, numBurnIn, numMCMCSteps, proposal), Proposal (SingleSiteMH))
import Control.Monad.Bayes.Inference.RMSMC (rmsmcDynamic)
import Control.Monad.Bayes.Inference.SMC (SMCConfig (SMCConfig, numParticles, numSteps, resampler), smc)
Expand All @@ -27,7 +27,6 @@ import HMM qualified
import LDA qualified
import LogReg qualified
import System.Process.Typed (runProcess)
import System.Random.Stateful (IOGenM, StatefulGen, StdGen, mkStdGen, newIOGenM)

data ProbProgSys = MonadBayes
deriving stock (Show)
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
};
};

cabal2nixOptions = "--benchmark";
cabal2nixOptions = "--benchmark -fdev";
};

jupyterEnvironment = mkJupyterlabFromPath ./kernels {inherit pkgs monad-bayes;};
Expand Down
2 changes: 1 addition & 1 deletion models/LDA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Control.Monad.Bayes.Class
MonadMeasure,
factor,
)
import Control.Monad.Bayes.Sampler.Strict (sampleIO, sampleIOfixed)
import Control.Monad.Bayes.Sampler.Strict (sampleIOfixed)
import Control.Monad.Bayes.Traced (mh)
import Control.Monad.Bayes.Weighted (unweighted)
import Data.Map qualified as Map
Expand Down
12 changes: 6 additions & 6 deletions monad-bayes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ library

if flag(dev)
ghc-options:
-Wall -Wno-missing-local-signatures -Wno-trustworthy-safe
-Wno-missing-import-lists -Wno-implicit-prelude
-Wno-monomorphism-restriction
-Wall -Werror -Wno-missing-local-signatures -Wno-trustworthy-safe
-Wno-missing-import-lists -Wno-implicit-prelude -Wno-name-shadowing
-Wno-monomorphism-restriction -Wredundant-constraints

else
ghc-options: -Wall
Expand Down Expand Up @@ -136,7 +136,7 @@ executable example

if flag(dev)
ghc-options:
-Wall -Wcompat -Wincomplete-record-updates
-Wall -Werror -Wcompat -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wnoncanonical-monad-instances

else
Expand Down Expand Up @@ -198,7 +198,7 @@ test-suite monad-bayes-test

if flag(dev)
ghc-options:
-Wall -Wno-missing-local-signatures -Wno-unsafe
-Wall -Werror -Wno-missing-local-signatures -Wno-unsafe
-Wno-missing-import-lists -Wno-implicit-prelude

else
Expand Down Expand Up @@ -252,7 +252,7 @@ benchmark speed-bench

if flag(dev)
ghc-options:
-Wall -Wno-missing-local-signatures -Wno-unsafe
-Wall -Werror -Wno-missing-local-signatures -Wno-unsafe
-Wno-missing-import-lists -Wno-implicit-prelude

else
Expand Down
2 changes: 1 addition & 1 deletion src/Control/Monad/Bayes/Inference/MCMC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mcmcDynamic (MCMCConfig {..}) m = burnIn numBurnIn $ unweighted $ Dynamic.mh num

-- -- | draw iid samples until you get one that has non-zero likelihood
independentSamples :: Monad m => Static.Traced m a -> P.Producer (MHResult a) m (Trace a)
independentSamples (Static.Traced w d) =
independentSamples (Static.Traced _w d) =
P.repeatM d
>-> P.takeWhile' ((== 0) . probDensity)
>-> P.map (MHResult False)
Expand Down
3 changes: 1 addition & 2 deletions src/Control/Monad/Bayes/Inference/TUI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import Control.Monad.Bayes.Enumerator (toEmpirical)
import Control.Monad.Bayes.Inference.MCMC
import Control.Monad.Bayes.Sampler.Strict (SamplerIO, sampleIO)
import Control.Monad.Bayes.Traced (Traced)
import Control.Monad.Bayes.Traced.Common
import Control.Monad.Bayes.Traced.Common hiding (burnIn)
import Control.Monad.Bayes.Weighted
import Control.Monad.State.Class (put)
import Data.Scientific (FPFormat (Exponent), formatScientific, fromFloatDigits)
import Data.Text qualified as T
import Data.Text.Lazy qualified as TL
Expand Down
2 changes: 1 addition & 1 deletion src/Control/Monad/Bayes/Sampler/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- | This is a port of the implementation of LazyPPL: https://lazyppl.bitbucket.io/
module Control.Monad.Bayes.Sampler.Lazy where

import Control.Monad (ap, liftM)
import Control.Monad (ap)
import Control.Monad.Bayes.Class (MonadDistribution (random))
import Control.Monad.Bayes.Weighted (Weighted, weighted)
import Numeric.Log (Log (..))
Expand Down
2 changes: 1 addition & 1 deletion src/Control/Monad/Bayes/Sampler/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ instance StatefulGen g m => MonadDistribution (Sampler g m) where
-- >>> import System.Random.Stateful hiding (random)
-- >>> newIOGenM (mkStdGen 1729) >>= sampleWith random
-- 4.690861245089605e-2
sampleWith :: StatefulGen g m => Sampler g m a -> g -> m a
sampleWith :: Sampler g m a -> g -> m a
sampleWith (Sampler m) = runReaderT m

-- | initialize random seed using system entropy, and sample
Expand Down
2 changes: 1 addition & 1 deletion src/Math/Integrators/StormerVerlet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Integrator a =
-- | Störmer-Verlet integration scheme for systems of the form
-- \(\mathbb{H}(p,q) = T(p) + V(q)\)
stormerVerlet2H ::
(Applicative f, Num (f a), Show (f a), Fractional a) =>
(Applicative f, Num (f a), Fractional a) =>
-- | Step size
a ->
-- | \(\frac{\partial H}{\partial q}\)
Expand Down
13 changes: 1 addition & 12 deletions test/TestAdvanced.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
module TestAdvanced where

import ConjugatePriors
( betaBernoulli',
betaBernoulliAnalytic,
gammaNormal',
gammaNormalAnalytic,
normalNormal',
normalNormalAnalytic,
)
import Control.Arrow
import Control.Monad (join, replicateM)
import Control.Monad (join)
import Control.Monad.Bayes.Class
import Control.Monad.Bayes.Enumerator
import Control.Monad.Bayes.Inference.MCMC
Expand All @@ -19,9 +11,6 @@ import Control.Monad.Bayes.Inference.SMC
import Control.Monad.Bayes.Inference.SMC2
import Control.Monad.Bayes.Population
import Control.Monad.Bayes.Sampler.Strict
import Control.Monad.Bayes.Traced
import Control.Monad.Bayes.Weighted
import Numeric.Log (Log)

mcmcConfig :: MCMCConfig
mcmcConfig = MCMCConfig {numMCMCSteps = 0, numBurnIn = 0, proposal = SingleSiteMH}
Expand Down
5 changes: 1 addition & 4 deletions test/TestDistribution.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ module TestDistribution
where

import Control.Monad (replicateM)
import Control.Monad.Bayes.Class (MonadDistribution, mvNormal)
import Control.Monad.Bayes.Class (mvNormal)
import Control.Monad.Bayes.Sampler.Strict
import Control.Monad.Identity (runIdentity)
import Control.Monad.State (evalStateT)
import Data.Matrix (fromList)
import Data.Vector qualified as V
import System.Random.MWC (toSeed)

-- Test the sampled covariance is approximately the same as the
-- specified covariance.
Expand Down
3 changes: 1 addition & 2 deletions test/TestInference.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import Control.Monad.Bayes.Inference.SMC
import Control.Monad.Bayes.Integrator (normalize)
import Control.Monad.Bayes.Integrator qualified as Integrator
import Control.Monad.Bayes.Population
import Control.Monad.Bayes.Population (collapse, runPopulation)
import Control.Monad.Bayes.Sampler.Strict (Sampler, sampleIOfixed)
import Control.Monad.Bayes.Sampler.Strict qualified as Sampler
import Control.Monad.Bayes.Weighted (Weighted)
import Control.Monad.Bayes.Weighted qualified as Weighted
import Data.AEq (AEq ((~==)))
import Numeric.Log (Log)
import Sprinkler (soft)
import System.Random.Stateful (IOGenM, StdGen, mkStdGen, newIOGenM)
import System.Random.Stateful (IOGenM, StdGen)

sprinkler :: MonadMeasure m => m Bool
sprinkler = Sprinkler.soft
Expand Down
2 changes: 1 addition & 1 deletion test/TestIntegrator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Control.Monad.Bayes.Class
import Control.Monad.Bayes.Integrator
import Control.Monad.Bayes.Sampler.Strict
import Control.Monad.Bayes.Weighted (weighted)
import Control.Monad.ST (ST, runST)
import Control.Monad.ST (runST)
import Data.AEq (AEq ((~==)))
import Data.List (sortOn)
import Data.Set (fromList)
Expand Down
2 changes: 0 additions & 2 deletions test/TestPipes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import Control.Monad.Bayes.Class ()
import Control.Monad.Bayes.Enumerator (enumerator)
import Data.AEq (AEq ((~==)))
import HMM (hmm, hmmPosterior)
import Pipes ((>->))
import Pipes.Prelude (toListM)
import qualified Pipes.Prelude as Pipes

urns :: Int -> Bool
urns n = enumerator (urn n) ~== enumerator (urnP n)
Expand Down
1 change: 0 additions & 1 deletion test/TestPopulation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Control.Monad.Bayes.Population as Population
import Control.Monad.Bayes.Sampler.Strict (sampleIOfixed)
import Data.AEq (AEq ((~==)))
import Sprinkler (soft)
import System.Random.Stateful (mkStdGen, newIOGenM)

weightedSampleSize :: MonadDistribution m => Population m a -> m Int
weightedSampleSize = fmap length . population
Expand Down
2 changes: 1 addition & 1 deletion test/TestSampler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import qualified Control.Foldl as Fold
import Control.Monad (replicateM)
import Control.Monad.Bayes.Class (MonadDistribution (normal))
import Control.Monad.Bayes.Sampler.Strict (sampleSTfixed)
import Control.Monad.ST (ST, runST)
import Control.Monad.ST (runST)

testMeanAndVariance :: Bool
testMeanAndVariance = isDiff
Expand Down
5 changes: 3 additions & 2 deletions test/TestStormerVerlet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import qualified Data.Vector as V
import qualified Linear as L
import Linear.V
import Math.Integrators.StormerVerlet
import Statistics.Function (square)

gConst :: Double
gConst = 6.67384e-11
Expand Down Expand Up @@ -81,8 +82,8 @@ energy x = keJ + keS + peJ + peS
qS = qs ^. _2
pJ = ps ^. _1
pS = ps ^. _2
keJ = (* 0.5) $ (/ jupiterMass) $ sum $ fmap (^ 2) pJ
keS = (* 0.5) $ (/ sunMass) $ sum $ fmap (^ 2) pS
keJ = (* 0.5) $ (/ jupiterMass) $ sum $ fmap square pJ
keS = (* 0.5) $ (/ sunMass) $ sum $ fmap square pS
r = qJ L.^-^ qS
ri = r `L.dot` r
peJ = 0.5 * gConst * sunMass * jupiterMass / (sqrt ri)
Expand Down
1 change: 0 additions & 1 deletion test/TestWeighted.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Control.Monad.State (unless, when)
import Data.AEq (AEq ((~==)))
import Data.Bifunctor (second)
import Numeric.Log (Log (Exp, ln))
import System.Random.Stateful (mkStdGen, newIOGenM)

model :: MonadMeasure m => m (Int, Double)
model = do
Expand Down

0 comments on commit a4d0c92

Please sign in to comment.