Skip to content

Instantly share code, notes, and snippets.

@danbst
Created April 14, 2014 23:00
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/10688720 to your computer and use it in GitHub Desktop.
Save danbst/10688720 to your computer and use it in GitHub Desktop.
Main.mapM_IndexReverse = (f :: GHC.Word.Word8 -> m ()) (PS payload rb1_a1UY offset length) ->
let return :: m ()
return = GHC.Base.return @ m $dMonad_a1Dq @ () GHC.Tuple.()
>> :: m () -> m () -> m ()
>> = GHC.Base.>> @ m $dMonad_a1Dq @ () @ ()
in
letrec {
loop :: Int# -> m ()
loop index ->
case index of
0 -> return
_ ->
let new_index = index -# 1
in (if new_index <# 0
then case check_negative_index new_index of wild2_00 { }
else
if new_index >=# length
then case check_index_too_large length new_index of wild2_00 { }
else
let (# world, word #) = readWord8OffAddr# RealWorld (plusAddr# payload (offset +# new_index)) 0 realWorld#
in case touch# GHC.ForeignPtr.ForeignPtrContents rb1_a1UY world of
_ -> f (W8# word)
)
>> loop new_index
in loop length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment