FizzBuzz in F# with functional programming Learning F#, created a somewhat elaborate fizzbuzz-builder implementation to see if I'm starting to "get" F# and thinking functionally:

type FBCase = FBCase of (int * string)

let makeFBCase num = FBCase (num, "")

let unpackFBCase case =
    match case with
    | FBCase (num, str) when str = "" -&gt; num |&gt; string
    | FBCase (_, str) -&gt; str

let fbBuilder (num) (str:string) input =
    match input with
    | FBCase (x, y) when x % num = 0 -&gt; FBCase (x, y+str)
    | _ -&gt; input

let createFBFunc input = fbBuilder (fst input) (snd input)

let createFBPipeline inputList =
    inputList
    |&gt; List.map createFBFunc
    |&gt; List.reduce (&gt;&gt;)

let createFBPattern inputList =
    makeFBCase
    &gt;&gt; (inputList |&gt; createFBPipeline)
    &gt;&gt; unpackFBCase

let fizzBuzz = createFBPattern [(3, "Fizz"); (5, "Buzz")]

let fizzBuzzBaz = createFBPattern [(3, "Fizz"); (5, "Buzz"); (7, "Baz")]

let fizzBuzzBazQuux = createFBPattern [(3, "Fizz"); (5, "Buzz"); (7, "Baz"); (11, "Quux")]

[1..100]
    |&gt; List.iter (fizzBuzz &gt;&gt; printfn "%A")
[1..100]
    |&gt; List.iter (fizzBuzzBaz &gt;&gt; printfn "%A")
[1..100]
    |&gt; List.iter (fizzBuzzBazQuux &gt;&gt; printfn "%A")


Where is it obvious that I'm not thinking functionally?
What could I change to make a more idiomatic F#-style program?
(Note that I don't really "get" monads or workflows yet, although I'm aware they exist).
I think it all seems quite functional. So nothing to argue about there. I like your use of List.reduce (&gt;&gt;).



Instead of the use of the union type FBCase, I would use the tuples directly in a way like this (some of the functions then may need a renaming):

let makeFBCase num = 
    (num, "")

let unpackFBCase (num, txt) =
    match txt with
    | "" -&gt; num |&gt; string
    | _ -&gt; txt

// Instead of input I use the tuple (num, text) to make it possible to call the elements directly
let fbBuilder (denom, str) (num, txt) =
    match num % denom with
    | 0 -&gt; (num, txt + str)
    | _ -&gt; (num, txt)

let createFBPipeline inputList =
    inputList |&gt; List.map fbBuilder |&gt; List.reduce (&gt;&gt;)

let createFBPattern inputList =
    makeFBCase &gt;&gt; (inputList |&gt; createFBPipeline) &gt;&gt; unpackFBCase

let fizzBuzz = createFBPattern [(3, "Fizz"); (5, "Buzz")]

let fizzBuzzBaz = createFBPattern [(3, "Fizz"); (5, "Buzz"); (7, "Baz")]

let fizzBuzzBazQuux = createFBPattern [(3, "Fizz"); (5, "Buzz"); (7, "Baz"); (11, "Quux")]


In this way I don't think you lose any clarity.



Although your efforts show a good understanding of details of functional programming, I think you make it all too complicated. The overall task is to map a list of integers to either the integer itself or a text in respect to one or more predicates. That can be done like this:

let fizzBuzz fizzBuzzes data =
    let checkFizzBuzzes value = 
        let result = fizzBuzzes |&gt; List.fold (fun acc (num, txt) -&gt; if value % num = 0 then sprintf "%s%s" acc txt else acc) ""
        match result with
        | "" -&gt; value |&gt; string
        | _ -&gt; result

    data |&gt; List.map checkFizzBuzzes

let data = [1..30]
data |&gt; fizzBuzz [ (3, "Fizz"); (5, "Buzz"); (7, "Baz"); (11, "Quux") ] |&gt; List.iter (printf "%s ")