[Haskell-cafe] System.Random.Shuffle fix

friggin friggin frigginfriggins at gmail.com
Mon Mar 23 13:10:37 EDT 2009

I was looking for a shuffling algorithm to shuffle mp3-playlists so was very
happy to see System.Random.Shuffle:

However I get  errors,non-exhaustive patterns in function shufleTree or
extractTree depending how I call it. Errors are at the bottom.

I fixed it but I don't have the math skills to see if I perhaps broke it
statistically ...

Here is my fix, someone (don't remember who, helped me a little):
the shuffle at the end is with the fix.

*Freet> S.shuffle [1..10] [1..3]
Loading package syb ... linking ... done.
Loading package base- ... linking ... done.
Loading package old-locale- ... linking ... done.
Loading package old-time- ... linking ... done.
Loading package random- ... linking ... done.
Loading package random-shuffle-0.0.2 ... linking ... done.
[2,4,6*** Exception: src\System\Random\Shuffle.hs:(52,6)-(55,30):
Non-exhaustive patterns in function shuffleTree

*Freet> S.shuffle [1..3] [1..10]
[2,*** Exception: src\System\Random\Shuffle.hs:(66,6)-(79,27):
Non-exhaustive patterns in function extractTree

*Freet> :load "c:/ghc/ghc-6.10.1/progs/Mp3Player/Shuffle.hs"
[1 of 1] Compiling Shuffle          (
C:\ghc\ghc-6.10.1\progs\Mp3Player\Shuffle.hs, interpreted )
Ok, modules loaded: Shuffle.
*Shuffle> shuffle [1..3] [1..10]
*Shuffle> shuffle [1..10] [1..3]
[2,4,6*** Exception:
C:\ghc\ghc-6.10.1\progs\Mp3Player\Shuffle.hs:(27,13)-(31,30): Non-exhaustive
patterns in function shuffle'

*Shuffle> shuffle [1..10] [1..10]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090323/e41a94c8/attachment.htm

More information about the Haskell-Cafe mailing list