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

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


import Data.Word
import Data.ByteString
import Data.ByteString.Fusion

-- Bug in the down/down (and all down) fusion rules.

k :: Int -> Word8 -> (PairS Int (MaybeS Word8))
k _ w = (0 :*: if w < 50 then NothingS else JustS 50)

-- Unfused
f k = loopWrapper (sequenceLoops (doDownLoop kk (0::Int)) (doDownLoop k (0::Int)))

-- Fused
g k = loopWrapper (doDownLoop (kk `fuseAccAccEFL` k) (0 :*: 0))

kk = \_ w -> (0 :*: JustS (w :: Data.Word.Word8))

s = Data.ByteString.pack [49,50,51]

main = do
    print "Should be the same:"
    print $ f k s
    print $ g k s

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].