infer :: (Ord a, FreshPickable a)
      => Context a
      -> LambdaTerm a
      -> Maybe (Context a, Type)
infer ctxt term = do (teC, te) <- runInference (inferTE (contextToTEContext ctxt) term)
                     let maxmax = maxTEConst te
                         newCtxt = teContextToContext (maxmax + 1) teC
                         newType = instantiateTypeVar (maxmax +1) te
                     return (newCtxt, newType)
infer :: (Ord a, FreshPickable a)
      => Context a
      -> LambdaTerm a
      -> Maybe (Context a, Type)
infer ctxt term = do (teC, te) <- runInference (inferTE (contextToTEContext ctxt) term)
                     let maxmax = maxTEConst te
                         newCtxt = teContextToContext (maxmax + 1) teC
                         newType = instantiateTypeVar (maxmax +1) te
                     return (newCtxt, newType)
infer ctxt term = do (teC, te) <- runInference (inferTE (contextToTEContext ctxt) term)
                     let maxmax = maxTEConst te
                         newCtxt = teContextToContext (maxmax + 1) teC
                         newType = instantiateTypeVar (maxmax +1) te
                     return (newCtxt, newType)