packages feed

acme-left-pad-2.0: Data/Text/LeftPad.hs

module Data.Text.LeftPad where

import Data.Text

leftPad :: String -> Int -> String -> String
leftPad s l "" = leftPad' s l ' '
leftPad s l (c:[]) = leftPad' s l c
  where leftPad' s 0 c = s
        leftPad' s n c = if length s > n then [c] ++ leftPad' s (n - 1) c else leftPad' s (n - 1) c