Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/libraries/fps/tests/fuse.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


--
-- Test array fusion
--

import Char
import qualified Data.ByteString as B

main = do ps <- B.getContents

--        print $ B.length . B.map (+1) $ ps

          let f = B.map (*4) . B.map (+2) . B.map (subtract 3) . B.map (+1) . B.map (*7)
          print $ B.length (f ps)

          let g = B.filter (/=104) . B.filter (/=102) . B.filter (/=103) . B.filter (/=104)
          print $ B.length (g ps)

          let h = B.filter (/=20) . B.map (+2) . B.filter (/=107) . B.map (+8)
          print $ B.length (h ps)   -- should fuse

          let i = B.map (+2) . B.filter (/=20) . B.map (+8). B.filter (/=107)
          print $ B.length (i ps)   -- should fuse

          print $ B.length $ (B.filter (/=7) . B.map (+8)) ps -- should fuse

          print $ B.length $ B.map (+7) ps -- shouldn't fuse

          print $ B.foldl (\a _ -> a+1::Int) 0 $ B.map (+7) ps -- should fuse

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].