Control.Applicativeについて学びました
PDFを読んだあとのFizzBuzz。リフトをスッキリと書けるところがいいですね。
import Control.Applicative import Data.Traversable fizz n = if n `mod` 3 == 0 then "Fizz" else "" buzz n = if n `mod` 5 == 0 then "Buzz" else "" toStr [x,y,z] | null x && null y = z | True = x ++ y fizzbuzz = toStr <$> sequenceA [fizz,buzz,show] <$> [1..100] main = mapM_ print fizzbuzz