Commit d764c0ce authored by eir@cis.upenn.edu's avatar eir@cis.upenn.edu

Add testcase for #8138

parent b082afa2
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Monad.ST
import Data.Primitive
main :: IO ()
main = do
let xs :: [Float] = runST $ do
barr <- mutableByteArrayFromList [1..fromIntegral n::Float]
peekByteArray n barr
print xs
where
n = 13
mutableByteArrayFromList :: forall s a . (Prim a)
=> [a]
-> ST s (MutableByteArray s)
mutableByteArrayFromList xs = do
arr <- newByteArray (length xs*sizeOf (undefined :: a))
loop arr 0 xs
return arr
where
loop :: (Prim a) => MutableByteArray s -> Int -> [a] -> ST s ()
loop _ _ [] = return ()
loop arr i (x : xs) = do
writeByteArray arr i x
loop arr (i+1) xs
peekByteArray :: (Prim a)
=> Int
-> MutableByteArray s
-> ST s [a]
peekByteArray n arr =
loop 0 arr
where
loop :: (Prim a)
=> Int
-> MutableByteArray s
-> ST s [a]
loop i _ | i >= n = return []
loop i arr = do
x <- readByteArray arr i
xs <- loop (i+1) arr
return (x : xs)
......@@ -45,4 +45,5 @@ test('Roles1', only_ways('normal'), compile, ['-ddump-tc'])
test('Roles2', only_ways('normal'), compile, ['-ddump-tc'])
test('Roles3', only_ways('normal'), compile, ['-ddump-tc'])
test('Roles4', only_ways('normal'), compile, ['-ddump-tc'])
test('Roles13', only_ways('normal'), compile, ['-ddump-simpl -dsuppress-uniques'])
\ No newline at end of file
test('Roles13', only_ways('normal'), compile, ['-ddump-simpl -dsuppress-uniques'])
test('T8138', normal, compile, ['-O2'])
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment