Commits

Aleksey Khudyakov committed f5c1a42

Add wrapper for condensed tables

Comments (0)

Files changed (2)

System/Random/MWC/CondensedTable/Monad.hs

+-- |
+-- Module    : System.Random.MWC.CondesedTable
+-- Copyright : (c) 2012 Aleksey Khudyakov
+-- License   : BSD3
+--
+-- Maintainer  : alexey.skladnoy@gmail.com
+-- Stability   : experimental
+-- Portability : portable
+--
+-- Monadic wrapper for 'System.Random.MWC.CondesedTable'.
+module System.Random.MWC.CondensedTable.Monad (
+    -- * Condensed tables
+    MWC.CondensedTable
+  , MWC.CondensedTableV
+  , MWC.CondensedTableU
+  , genFromTable
+    -- * Constructors for tables
+  , MWC.tableFromProbabilities
+  , MWC.tableFromWeights
+  , MWC.tableFromIntWeights
+    -- ** Disrete distributions
+  , MWC.tablePoisson
+  , MWC.tableBinomial
+  ) where
+
+import Control.Monad.Primitive         (PrimMonad)
+import qualified Data.Vector.Generic as G
+import System.Random.MWC.Monad
+import qualified System.Random.MWC.CondensedTable as MWC
+
+
+genFromTable :: (PrimMonad m, G.Vector v a) => MWC.CondensedTable v a -> Rand m a
+genFromTable tbl = toRand $ \g -> MWC.genFromTable tbl g
+{-# INLINE genFromTable #-}

mwc-random-monad.cabal

                      mwc-random >= 0.11
   Exposed-modules:   System.Random.MWC.Monad
                      System.Random.MWC.Distributions.Monad
+                     System.Random.MWC.CondensedTable.Monad
   Ghc-options:       -O2 -Wall
   Ghc-prof-options:  -auto-all