Created
January 4, 2010 00:40
-
-
Save eagletmt/268210 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Array | |
import Data.Array.IArray (IArray) | |
import Data.Array.Unboxed (UArray) | |
import Data.Array.ST (STArray, thaw, freeze) | |
import Control.Monad.ST (ST, runST) | |
coerce :: (Ix i, IArray a e, IArray b e) => a i e -> b i e | |
coerce arr = runST $ thawST arr >>= freeze | |
where | |
thawST :: (Ix i, IArray a e) => a i e -> ST s (STArray s i e) | |
thawST = thaw | |
main = print $ (coerce $ listArray (0,3) [0..3] :: UArray Int Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment