Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created March 7, 2010 14:23
Show Gist options
  • Save jutememo/324385 to your computer and use it in GitHub Desktop.
Save jutememo/324385 to your computer and use it in GitHub Desktop.
-- ページ
data Page = Page [String]
-- 文字列をページに変換
toPage :: String -> Page
toPage = Page . lines
main = getContents >>= print . toPage
instance Show Page where
show (Page ls) = unlines $ map (padding 6) (zip [1..] ls)
-- 行 line に幅 width で行番号 n をふる
padding width (n,line) = spaces ++ num ++ " " ++ line
where
spaces = replicate (width - length num) ' '
num = show n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment