A little literate Haskell program:
> module Fizzbuzz where
So, fizz-buzz through a functional lens
> import Control.Arrow
Our predicate is for some number, x, we print 'fizz' if it's modulo 3,
or we print 'buzz' if it's modulo 5. N.b.: these predicates are not
So our fizz-buzz predicate follows ('pred'icate 'f'izz-'b'uzz)
> predfb :: String -> Int -> Int -> Either String Int
> predfb str modulo x | x `mod` modulo == 0 = Left str
> | otherwise = Right x
> fizz = predfb "fizz" 3
> buzz = predfb "buzz" 5
... that's really all there is so we just split the input number
into the two predicates and then remerge the results following
Left str1 (+) Left str2 = str1 ++ str2
Left str (+) _ = str
_ (+) Left str = str
Right x (+) _ = show x
which transliterates quite nicely (it's nice programming requirement specification as implementation-code when your programming language is declarative)
> fbprinter :: (Either String Int, Either String Int) -> String
> fbprinter (Left x, Left y) = x ++ y
> fbprinter (Left x, _) = x
> fbprinter (_, Left y) = y
> fbprinter (Right num, _) = show num
Now the fizz-buzz game: count from 1 to 100 replacing '3's with fizz and '5's
with 'buzz' ... off you go:
> fizzbuzz = [1..100] >>= return . (fizz &&& buzz >>> fbprinter)
There it is. fizzbuzz in, lessee, 8 lines of implementation code. Any questions?
Well, there is one improvement. If we look at the Either type as a cartesian
product type (which it is), then the print rule looks rather redundant to the
monoidal append operation, for, after all
m0 (+) (anything) = (anything) (order of arguments superfluous); and,
m+ (+) m+ = defined by the semigroupoid-implementation
so, the monoidal addition of lists is
 (+) lst = lst; and, (... even if lst == )
lst1 (+) lst2 = lst1 ++ lst2
Can't we just convert our Either String Int type to be a monoid and have
the special base case of 'show num' for the (Right num (+) Right num) case?
Hm. Yes. I leave this now as an exercise for the reader...
... which is another way of saying that I see a simple solution of
mzero == Right num
mplus == Left str
in my head, but how to implement that in Haskell is currently puzzling me.
Intrepid readers, show me the light!
... at any rate, 'running' fizzbuzz gets you all fizzy-buzzy and you can feel good that you've used a little predicate logic, functional programming, programming with arrows, no less, and you didn't have any redundant boolean logic that you see in other implementation for fizz-buzz: Either took care guarding our conditioned results.