Exemplo n.º 1
0
Arquivo: nat.py Projeto: xchani/tvm
def define_nat_adt(prelude):
    """Defines a Peano (unary) natural number ADT.
    Zero is represented by z(). s(n) adds 1 to a nat n.
    Adds the fields nat, z, and s to the preluide, representing
    (respectively) the nat ADT and the z and s constructors.
    """
    prelude.nat = GlobalTypeVar("nat")
    prelude.z = Constructor("z", [], prelude.nat)
    prelude.s = Constructor("s", [prelude.nat()], prelude.nat)
    prelude.mod[prelude.nat] = TypeData(prelude.nat, [], [prelude.z, prelude.s])
Exemplo n.º 2
0
def test_type_call():
    tc = TypeCall(GlobalTypeVar("tf"), [TupleType([])])
    check_visit(tc)
Exemplo n.º 3
0
def test_type_data():
    td = TypeData(GlobalTypeVar("td"), [TypeVar("tv")], [])
    check_visit(td)
Exemplo n.º 4
0
def test_global_type_var():
    gtv = GlobalTypeVar("gtv")
    check_visit(gtv)
Exemplo n.º 5
0
def test_type_data():
    td = TypeData(GlobalTypeVar('td'), [TypeVar('tv')], [])
    check_visit(td)