 
 # An empty finger tree.
 Empty = {
-  reducel: (z, op) -> z
-  reducer: (op, z) -> z
+  reduceLeft:  (z, op) -> z
+  reduceRight: (op, z) -> z
 }
 
 

class Single
  constructor: (a) -> @a = a

  reducel: (z, op) -> op z, @a
  reducer: (op, z) -> op @a, z


# A deep finger tree.

# A digit in a finger tree.
class Digit1
  constructor: -> [@a] = arguments
  reduceLeft:  (z, op) -> op(z, @a)
  reduceRight: (op, z) -> op(@a, z)

class Digit2
  constructor: -> [@a, @b] = arguments
  reduceLeft:  (z, op) -> op(op(z, @a), @b)
  reduceRight: (op, z) -> op(@a, op(@b, z))

class Digit3
  constructor: -> [@a, @b, @c] = arguments
  reduceLeft:  (z, op) -> op(op(op(z, @a), @b), @c)
  reduceRight: (op, z) -> op(@a, op(@b, op(@c, z)))

class Digit4
  constructor: -> [@a, @b, @c, @d] = arguments
  reduceLeft:  (z, op) -> op(op(op(op(z, @a), @b), @c), @d)
  reduceRight: (op, z) -> op(@a, op(@b, op(@c, op(@d, z))))

makeDigit = (args...) ->
  type = switch args.length
    when 1 then Digit1
    when 2 then Digit2
