Is this a reasonable Scala monad?
What you are describing are simply functions.

To take a related example from mathematics, 

          /   x, if x &gt;= 0
abs(x) =  |
          \  -x, otherwise


And you are just composing functions: f(g(x)).

You can somewhat make the correspondence to monads, but it is a bit of a stretch.  I think it is more that monads are extensions of functions rather than the other way around.

flatMap would be the composition operator: o  , ie (f o g)(x) = f(g(x)).  And unit would just be the identity operation: I(x) = x.

The three monad laws:


Associativity: f o (g o h) = (f o g) o h
Left unit: I o f = f
Right unit: f o I = f


So instead of defining your If class, you can just stick to def, the usual function definition.  Functional programming!!!  In your case you can compose all your functions in any order since they always input/output Foo type.  You can compose functions in Scala with val h = f _ compose h _, or using andThen.