opentheory-probability (empty) → 1.46
raw patch · 6 files changed
+120/−0 lines, 6 filesdep +QuickCheckdep +basedep +opentheorysetup-changed
Dependencies added: QuickCheck, base, opentheory, opentheory-primitive
Files
- LICENSE +17/−0
- Setup.hs +6/−0
- opentheory-probability.cabal +29/−0
- src/OpenTheory/List/Geometric.hs +21/−0
- src/OpenTheory/Natural/Geometric.hs +24/−0
- src/OpenTheory/Random.hs +23/−0
+ LICENSE view
@@ -0,0 +1,17 @@+Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,6 @@+module Main(main)++import Distribution.Simple++main :: IO ()+main = defaultMain
+ opentheory-probability.cabal view
@@ -0,0 +1,29 @@+name: opentheory-probability+version: 1.46+category: Formal Methods+synopsis: Probability+license: MIT+license-file: LICENSE+cabal-version: >= 1.8.0.2+build-type: Simple+author: Joe Leslie-Hurd <joe@gilith.com>+maintainer: Joe Leslie-Hurd <joe@gilith.com>+description:+ Probability - this package was automatically generated from the+ OpenTheory package probability-1.46++library+ build-depends:+ base >= 4.0 && < 5.0,+ QuickCheck >= 2.4.0.1 && < 3.0,+ opentheory-primitive >= 1.3 && < 2.0,+ opentheory >= 1.193 && < 1.196++ hs-source-dirs: src++ ghc-options: -Wall++ exposed-modules:+ OpenTheory.List.Geometric+ OpenTheory.Natural.Geometric+ OpenTheory.Random
+ src/OpenTheory/List/Geometric.hs view
@@ -0,0 +1,21 @@+{- |+module: $Header$+description: Probability+license: MIT++maintainer: Joe Leslie-Hurd <joe@gilith.com>+stability: provisional+portability: portable+-}++module OpenTheory.List.Geometric+where++import qualified OpenTheory.Natural.Geometric as Geometric+import qualified OpenTheory.Primitive.Random as Primitive.Random+import qualified OpenTheory.Random as Random++random :: (Primitive.Random.Random -> a) -> Primitive.Random.Random -> [a]+random f r =+ let (r1, r2) = Primitive.Random.split r in+ Random.vector f (Geometric.random r1) r2
+ src/OpenTheory/Natural/Geometric.hs view
@@ -0,0 +1,24 @@+{- |+module: $Header$+description: Probability+license: MIT++maintainer: Joe Leslie-Hurd <joe@gilith.com>+stability: provisional+portability: portable+-}++module OpenTheory.Natural.Geometric+where++import qualified OpenTheory.Primitive.Natural as Natural+import qualified OpenTheory.Primitive.Random as Random++random :: Random.Random -> Natural.Natural+random =+ loop 0+ where+ {-loop :: Natural.Natural -> Random.Random -> Natural.Natural-}+ loop n r =+ let (r1, r2) = Random.split r in+ if Random.bit r1 then n else loop (n + 1) r2
+ src/OpenTheory/Random.hs view
@@ -0,0 +1,23 @@+{- |+module: $Header$+description: Probability+license: MIT++maintainer: Joe Leslie-Hurd <joe@gilith.com>+stability: provisional+portability: portable+-}++module OpenTheory.Random+where++import qualified OpenTheory.Primitive.Natural as Natural+import qualified OpenTheory.Primitive.Random as Random++vector :: (Random.Random -> a) -> Natural.Natural -> Random.Random -> [a]+vector f n r =+ if n == 0 then []+ else let (r1, r2) = Random.split r in f r1 : vector f (n - 1) r2++bits :: Natural.Natural -> Random.Random -> [Bool]+bits = vector Random.bit