 
       concat: (t) -> t
 
-      norm: -> measurement.empty
+      measure: -> norm()
     }
 
 


      concat: (t) -> t.after @a

      norm: -> norm @a


    # A deep finger tree.

  { Sequence } = pazy


SizeMeasure =
  empty:  0
  single: (x) -> 1
  sum:    (a, b) -> a + b


class FingerTreeType
  constructor: (measure = SizeMeasure) ->
    T = this
    norm = ->
      Sequence.reduce arguments, measure.empty, (n, x) ->
        if x?
          t = switch x.constructor
            when T.Node2, T.Node3 then x.measure()
            else measure.single(x)
          measure.sum n, t
        else
          n

    # A node.
    @Node2 = class
      constructor: ->
        [@a, @b] = arguments
        @v = norm @a, @b

      reduceLeft:  (z, op) -> op(op(z, @a), @b)
      reduceRight: (op, z) -> op(@a, op(@b, z))
      asDigit: -> new T.Digit2 @a, @b
      measure: -> @v

    @Node3 = class
      constructor: ->
        [@a, @b, @c] = arguments
        @v = norm @a, @b, @c

      reduceLeft:  (z, op) -> op(op(op(z, @a), @b), @c)
      reduceRight: (op, z) -> op(@a, op(@b, op(@c, z)))
      asDigit: -> new T.Digit3 @a, @b, @c
      measure: -> @v


    # A digit in a finger tree.
