shiftDown :: Def ('[ Ref s0 ('Stored Uint8)
                   , Ref s1 ('Stored Uint32), Ref s2 ('Stored Uint8)
                   , ConstRef s3 ('Stored Uint32), ConstRef s4 ('Stored Uint8)
                   ] ':-> IBool)
shiftDown = proc "shift_task_down" $ \ target_ref current_prio current_task next_prio next_task -> body $ do
  target <- deref target_ref
  when (target ==? maxBound) $ ret true
  current <- deref current_task
  when (current ==? target) $ do
    refCopy current_prio next_prio
    refCopy current_task next_task
    comment "We just duplicated the next task, so arrange to delete that next."
    refCopy target_ref next_task
  ret false

-- | These definitions do not depend on the number of mailboxes or
-- tasks, so factor them into a separate module to reduce code
-- duplication.
shiftDown :: Def ('[ Ref s0 ('Stored Uint8)
                   , Ref s1 ('Stored Uint32), Ref s2 ('Stored Uint8)
                   , ConstRef s3 ('Stored Uint32), ConstRef s4 ('Stored Uint8)
                   ] ':-> IBool)
shiftDown = proc "shift_task_down" $ \ target_ref current_prio current_task next_prio next_task -> body $ do
  target <- deref target_ref
  when (target ==? maxBound) $ ret true
  current <- deref current_task
  when (current ==? target) $ do
    refCopy current_prio next_prio
    refCopy current_task next_task
    comment "We just duplicated the next task, so arrange to delete that next."
    refCopy target_ref next_task
  ret false

-- | These definitions do not depend on the number of mailboxes or
-- tasks, so factor them into a separate module to reduce code
-- duplication.
shiftDown = proc "shift_task_down" $ \ target_ref current_prio current_task next_prio next_task -> body $ do
  target <- deref target_ref
  when (target ==? maxBound) $ ret true
  current <- deref current_task
  when (current ==? target) $ do
    refCopy current_prio next_prio
    refCopy current_task next_task
    comment "We just duplicated the next task, so arrange to delete that next."
    refCopy target_ref next_task
  ret false

-- | These definitions do not depend on the number of mailboxes or
-- tasks, so factor them into a separate module to reduce code
-- duplication.