
from .ast import *
from .. import core

from ..tool import extends, producer

@extends(Definition)
@producer
def typecheck(self, state):

    value = self.value
    
    # recursive functions by default
    if type(value) is core.ast.Abs:
        value = self.fix()
        
    mono = yield from value.typecheck(state)
    state.declare(self.name, mono)

    return None



@extends(Expr)
@producer
def typecheck(self, state):
    mono = yield from self.value.typecheck(state)
    return mono

