def type_fun(t): if t is None or init_type is None: return None try: (c, a) = t.type except (TypeError, ValueError): raise types.FTypeException("%s not an instance of (c * E a)" % a) f_out_type = f.type_fun(types.FType((init_type.type, a.type))) if not types.is_of_type(f_out_type, init_type): raise types.FTypeException( "%s not of expected type: f generates %s instead of %s" % (t, f_out_type, init_type)) return types.FType((c, init_type.type))
def type_fun(in_type): if in_type is None: return None try: (a, c) = in_type.type except ValueError: raise types.FTypeException("%s not of type (a * c)" % in_type) return types.FType((ef1.type_fun(types.FType(a)).type, c))
def type_fun(a): if a is None or c_type is None: return None eftype = ef1.type_fun(types.FType((a.type, c_type.type))) if eftype is None: return None (b, c) = eftype.type if not types.is_of_type(c_type, types.FType(c)): raise types.FTypeException("%s is not of type %s" % (c, c_type)) return types.FType(b)
def Split(e): e1 = None e2 = None def prepare(): e1.fresh = False e2.fresh = False for l in e1.listeners.itervalues(): l.prepare() for l in e2.listeners.itervalues(): l.prepare() def push((x1, x2)): for l in e1.listeners.itervalues(): l.push(x1) for l in e2.listeners.itervalues(): l.push(x2) def finish(): for l in e1.listeners.itervalues(): l.finish() for l in e2.listeners.itervalues(): l.finish() e1.fresh = True e2.fresh = True def terminate(): for l in e1.listeners.itervalues(): l.terminate() for l in e2.listeners.itervalues(): l.terminate() t1 = t2 = None if e.type is not None: try: (r1, r2) = e.type.type (t1, t2) = (types.FType(r1), types.FType(r2)) except (TypeError, ValueError): raise types.FTypeException("%s not of type %s" % (e.type, "a * b")) e1 = FEvent(type=t1) e2 = FEvent(type=t2) e.add_listener(FListener(prepare, push, finish, terminate)) return (e1, e2)
def type_fun(test_in_type): if in_type is None or types.is_of_type(test_in_type, in_type): return out_type else: raise types.FTypeException("%s not of type %s" % (test_in_type, in_type))