packages feed

perfect-vector-shuffle-0.1.1.2: perfect-vector-shuffle.cabal

cabal-version:      2.2
category:           Random, Vector
build-type:         Simple

name:               perfect-vector-shuffle
synopsis:           Library for performing vector shuffles
version:            0.1.1.2

author:             Callan McGill
maintainer:         callan.mcgill@gmail.com
homepage:           https://github.com/Boarders/perfect-vector-shuffle
bug-reports:        https://github.com/Boarders/perfect-vector-shuffle/issues
copyright:          2019
license:            BSD-3-Clause
description:
    .
    This package contains functions for performing in-place Fisher--Yates
    shuffles on mutable and immutable vectors along with some related
    functionality. The shuffles are uniform at random amongst all
    permuations.
    .
    For an example of how to use it:
    .
    @
        module Main where
        .
        import Data.Vector
        import Immutable.Shuffle
        .
        main :: IO ()
        main = do {
        shuffleMyVector >>= print;
        cycleMyVector   >>= print;
        derangeMyVector >>= print;
        }
        .
        myVector :: Vector Int
        myVector = fromList [1..10]
        .
        shuffleMyVector :: IO (Vector Int)
        shuffleMyVector = shuffleM myVector
        .
        cycleMyVector :: IO (Vector Int)
        cycleMyVector = maximalCycleM myVector
        .
        derangeMyVector :: IO (Vector Int)
        derangeMyVector = derangementM myVector
    @
    .
    This gives the following:
    .
    @
    >>> main
      [2,8,1,5,10,9,7,3,6,4]
      [6,8,4,10,9,2,5,7,3,1]
      [8,5,4,1,10,9,3,6,2,7]
    .
    >>> main
      [7,9,3,5,10,6,8,1,2,4]
      [2,4,10,7,8,1,5,9,3,6]
      [4,8,5,2,7,3,9,6,10,1]
    @

extra-doc-files: CHANGELOG.md


source-repository head
  type:     git
  location: https://github.com/Boarders/perfect-vector-shuffle


Library

  hs-source-dirs:   src

  ghc-options:      -Wall
                    -fexpose-all-unfoldings
                    -fspecialise-aggressively

  build-depends:    base        >= 4.9      && < 4.20
                  , MonadRandom >= 0.5.1.1  && < 0.7
                  , primitive   >= 0.6.4    && < 0.9
                  , random      >= 1.1      && < 1.3
                  , vector      >= 0.12.0   && < 0.14

  exposed-modules:  Immutable.Shuffle
                    Mutable.Shuffle

  other-modules:

  default-language: Haskell2010


Test-Suite testsuite

  type:             exitcode-stdio-1.0

  main-is:          Test.hs

  hs-source-dirs:   test

  ghc-options:      -Wall
                    -fexpose-all-unfoldings
                    -fspecialise-aggressively
                    -Wincomplete-patterns

  build-depends:    perfect-vector-shuffle
                  , base                   
                  , QuickCheck             
                  , random                 
                  , tasty                  
                  , tasty-quickcheck       
                  , vector                 
                  , quickcheck-instances   


  other-modules:    Immutable.Test
                    Mutable.Test

  default-language: Haskell2010


Executable example

  main-is:          Example.hs

  hs-source-dirs:   src

  ghc-options:      -Wall
                    -fexpose-all-unfoldings
                    -fspecialize-aggressively
                    -Wincomplete-patterns

  build-depends:    perfect-vector-shuffle
                  , base
                  , MonadRandom
                  , primitive
                  , random
                  , vector

  other-modules: Immutable.Shuffle
                 Mutable.Shuffle


  default-language: Haskell2010