-- | Measure the message lengths generated by different encodings.
measure :: (Binary a, Typeable a) => String -> a -> EncodeLengths
measure i x = EL { info = i
                 , binary         = BSL.length binary'
                 , typedUntyped   = BSL.length typedUntyped'
                 , typedHashed32  = BSL.length typedHashed32'
                 , typedHashed64  = BSL.length typedHashed64'
                 , typedShown     = BSL.length typedShown'
                 , typedFull      = BSL.length typedFull'
                 }

      where

      binary'        = encode                x
      typedUntyped'  = encodeTyped  Untyped  x
      typedHashed32' = encodeTyped  Hashed32 x
      typedHashed64' = encodeTyped  Hashed64 x
      typedShown'    = encodeTyped  Shown    x
      typedFull'     = encodeTyped  Full     x
measure :: (Binary a, Typeable a) => String -> a -> EncodeLengths
measure i x = EL { info = i
                 , binary         = BSL.length binary'
                 , typedUntyped   = BSL.length typedUntyped'
                 , typedHashed32  = BSL.length typedHashed32'
                 , typedHashed64  = BSL.length typedHashed64'
                 , typedShown     = BSL.length typedShown'
                 , typedFull      = BSL.length typedFull'
                 }

      where

      binary'        = encode                x
      typedUntyped'  = encodeTyped  Untyped  x
      typedHashed32' = encodeTyped  Hashed32 x
      typedHashed64' = encodeTyped  Hashed64 x
      typedShown'    = encodeTyped  Shown    x
      typedFull'     = encodeTyped  Full     x
measure i x = EL { info = i
                 , binary         = BSL.length binary'
                 , typedUntyped   = BSL.length typedUntyped'
                 , typedHashed32  = BSL.length typedHashed32'
                 , typedHashed64  = BSL.length typedHashed64'
                 , typedShown     = BSL.length typedShown'
                 , typedFull      = BSL.length typedFull'
                 }

      where

      binary'        = encode                x
      typedUntyped'  = encodeTyped  Untyped  x
      typedHashed32' = encodeTyped  Hashed32 x
      typedHashed64' = encodeTyped  Hashed64 x
      typedShown'    = encodeTyped  Shown    x
      typedFull'     = encodeTyped  Full     x