Skip to content

Instantly share code, notes, and snippets.

@danbst
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbst/10687430 to your computer and use it in GitHub Desktop.
Save danbst/10687430 to your computer and use it in GitHub Desktop.
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