summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/setByteArray.hs
blob: 099376cb4b98a26c11f33cb7501865d649ce2d32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples #-}
{-# OPTIONS_GHC -Wall #-}

module Main ( main ) where

import GHC.Base

data BA = BA ByteArray#

-- Checks that setByteArray# works
main :: IO ()
main = do BA ba <- IO $ \s0 ->
                        case newByteArray# 8# s0 of
                        (# !s1, !mba #) ->
                            case setByteArray# mba 0# 8# 65# s1 of
                            !s2 ->
                                case setByteArray# mba 1# 6# 67# s2 of
                                !s3 ->
                                    case unsafeFreezeByteArray# mba s3 of
                                    (# s4, ba #) -> (# s4, BA ba #)
          let f (I# i) = putStrLn [C# (indexCharArray# ba i)]
          mapM_ f [0..7]