import Data.List (group)


type Encoded = [(Int, Char)] 

type Decoded = String


rlencode :: Decoded -> Encoded
rlencode = fmap ((,) <$> length <*> head) . group


rldecode :: Encoded -> Decoded
rldecode = concatMap (uncurry replicate)

main :: IO ()
main = do
  let input = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
      
      encoded = rlencode input
      decoded = rldecode encoded
  putStrLn $ "Encoded: " <> show encoded <> "\nDecoded: " <> show decoded