Last active
August 29, 2015 13:59
-
-
Save danbst/10687430 to your computer and use it in GitHub Desktop.
This file contains 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
Main.mapM_Unpack (f :: Word8 -> m ()) (PS payload rb1_a1Tf offset length) -> | |
let { | |
>> :: m () -> m () -> m () | |
>> = GHC.Base.>> @ m $dMonad_a1E5 @ () @ () } | |
in | |
letrec { | |
loop :: Addr# -> Int# -> m () -> GHC.Prim.State# GHC.Prim.RealWorld -> (# GHC.Prim.State# GHC.Prim.RealWorld, m () #) | |
loop addr index default_m world -> | |
case index of | |
(-1) -> (# world, default_m #) | |
_ -> let (# world2, word #) = case readWord8OffAddr# (plusAddr# addr index) 0 world | |
in loop addr (index -# 1) ((f (W8# word)) >> default_m) world2 | |
} | |
in let (# world3, result #) = loop (plusAddr# payload offset) (length -# 1) (return ()) GHC.Prim.realWorld# | |
in case touch# GHC.ForeignPtr.ForeignPtrContents rb1_a1Tf world3 of | |
_ -> result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment