Package translate :: Package misc :: Package typecheck :: Module typeclasses |
[hide private]
[frames] | no frames]

# Source Code for Module translate.misc.typecheck.typeclasses

     1  from translate.misc.typecheck import Typeclass
     2
     3  ### Number
     4  ####################################################
     5
     6  _numbers = [int, float, complex, long, bool]
     7  try:
     8      from decimal import Decimal
     9      _numbers.append(Decimal)
    10      del Decimal
    11  except ImportError:
    12      pass
    13
    14  Number = Typeclass(*_numbers)
    15  del _numbers
    16
    17  ### String -- subinstance of ImSequence
    18  ####################################################
    19
    20  String = Typeclass(str, unicode)
    21
    22  ### ImSequence -- immutable sequences
    23  ####################################################
    24
    25  ImSequence = Typeclass(tuple, xrange, String)
    26
    27  ### MSequence -- mutable sequences
    28  ####################################################
    29
    30  MSequence = Typeclass(list)
    31
    32  ### Mapping
    33  ####################################################
    34
    35  Mapping = Typeclass(dict)
    36