def typed(ruletypes):
 return switch(type, ruletypes)

def typed ( ruletypes ) : return switch ( type , ruletypes )
apply rules based on the expression type inputs: ruletypes -- a dict mapping {type: rule} .