permutation-0.5.0.5: A library for permutations and combinations.

CopyrightCopyright (c) Patrick Perry <patperry@stanford.edu>
LicenseBSD3
MaintainerPatrick Perry <patperry@stanford.edu>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Data.Permute.ST

Contents

Description

Mutable permutations in the ST monad.

Synopsis

Permutations

data STPermute s #

A mutable permutation that can be manipulated in the ST monad. The type argument s is the state variable argument for the ST type.

Instances

Eq (STPermute s) # 

Methods

(==) :: STPermute s -> STPermute s -> Bool #

(/=) :: STPermute s -> STPermute s -> Bool #

MPermute (STPermute s) (ST s) # 

Methods

getSize :: STPermute s -> ST s Int #

newPermute :: Int -> ST s (STPermute s) #

newPermute_ :: Int -> ST s (STPermute s) #

unsafeGetElem :: STPermute s -> Int -> ST s Int #

unsafeSetElem :: STPermute s -> Int -> Int -> ST s () #

unsafeSwapElems :: STPermute s -> Int -> Int -> ST s () #

getElems :: STPermute s -> ST s [Int] #

setElems :: STPermute s -> [Int] -> ST s () #

unsafeFreeze :: STPermute s -> ST s Permute #

unsafeThaw :: Permute -> ST s (STPermute s) #

unsafeInterleaveM :: ST s a -> ST s a

runSTPermute :: (forall s. ST s (STPermute s)) -> Permute #

A safe way to create and work with a mutable permutation before returning an immutable one for later perusal. This function avoids copying the permutation before returning it - it uses unsafeFreeze internally, but this wrapper is a safe interface to that function.

Overloaded mutable permutation interface