meowlang/typechecker/types/GenericFunctionTypeDescription.cs

21 lines
791 B
C#
Raw Normal View History

namespace meowlang.typechecker;
public record GenericFunctionTypeDescription : GenericTypeDescription
{
private readonly List<GenericTypeId> _parameters;
private readonly List<GenericTypeId> _returns;
public GenericFunctionTypeDescription(List<string> genericNames, List<GenericTypeId> parameters, List<GenericTypeId> returns) : base(genericNames)
{
_parameters = parameters;
_returns = returns;
}
public override FunctionTypeDescription Concretize(List<Guid> typeParams)
{
var parameters = _parameters.Select(x => ConcretizeGenericType(x, typeParams)).ToList();
var returns = _returns.Select(x => ConcretizeGenericType(x, typeParams)).ToList();
return new FunctionTypeDescription(parameters, returns);
}
};