Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. module Main where
  2.  
  3. import Data.Word
  4. import qualified Data.ByteString as X
  5.  
  6. convert :: X.ByteString -> X.ByteString
  7. convert = X.tail . X.scanl (\a b -> if isSpace a then toUpper b else b) 32
  8.  
  9. isSpace :: Word8 -> Bool
  10. isSpace w = if w == 32 || w == 10 then True else False
  11. {-# INLINE isSpace #-}
  12.  
  13. toUpper :: Word8 -> Word8
  14. toUpper w = if w > 96 && w < 123 then w - 32 else w
  15. {-# INLINE toUpper #-}
  16.  
  17. main = do
  18.     name <- X.readFile "file"
  19.     X.putStr $ convert name