------------------------------------------------------------------------------
-- | Pawn captures (from, to) including promotions, excluding advances or
-- en Passant
pawnCaptureSquares :: Board -> [ (Square, Square, Maybe Square) ]
pawnCaptureSquares b = do
  let myPawns = myPiecesOf b Pawn
      -- files from which we can left/right capture
      cFiles 7 White = complement $ fileBB aFile
      cFiles 9 White = complement $ fileBB hFile
      cFiles 7 Black = complement $ fileBB hFile
      cFiles 9 Black = complement $ fileBB aFile
      cFiles _ _       = error "Unexpected numbers"
  capture <- [7, 9]  -- left and right capture
  target  <- toList $ opponentsPieces b .&.
             ((myPawns .&. cFiles capture (b^.next))
              `shift` direction (b^.next) capture)
  return (offset target (direction (b^.B.opponent) capture), target, Nothing)


------------------------------------------------------------------------------
-- Pawn advances (from, to) including promotions, excluding captures
pawnCaptureSquares :: Board -> [ (Square, Square, Maybe Square) ]
pawnCaptureSquares b = do
  let myPawns = myPiecesOf b Pawn
      -- files from which we can left/right capture
      cFiles 7 White = complement $ fileBB aFile
      cFiles 9 White = complement $ fileBB hFile
      cFiles 7 Black = complement $ fileBB hFile
      cFiles 9 Black = complement $ fileBB aFile
      cFiles _ _       = error "Unexpected numbers"
  capture <- [7, 9]  -- left and right capture
  target  <- toList $ opponentsPieces b .&.
             ((myPawns .&. cFiles capture (b^.next))
              `shift` direction (b^.next) capture)
  return (offset target (direction (b^.B.opponent) capture), target, Nothing)


------------------------------------------------------------------------------
-- Pawn advances (from, to) including promotions, excluding captures
pawnCaptureSquares b = do
  let myPawns = myPiecesOf b Pawn
      -- files from which we can left/right capture
      cFiles 7 White = complement $ fileBB aFile
      cFiles 9 White = complement $ fileBB hFile
      cFiles 7 Black = complement $ fileBB hFile
      cFiles 9 Black = complement $ fileBB aFile
      cFiles _ _       = error "Unexpected numbers"
  capture <- [7, 9]  -- left and right capture
  target  <- toList $ opponentsPieces b .&.
             ((myPawns .&. cFiles capture (b^.next))
              `shift` direction (b^.next) capture)
  return (offset target (direction (b^.B.opponent) capture), target, Nothing)


------------------------------------------------------------------------------
-- Pawn advances (from, to) including promotions, excluding captures