Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (39 sloc)
1.23 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Amateurlog | |
{ | |
abstract partial record Type : IUnifiable<Type> | |
{ | |
public abstract string? AsVariable(); | |
public abstract bool Match(Type right); | |
} | |
partial record TypeVariable : Type | |
{ | |
public override string? AsVariable() => Name; | |
public override bool Match(Type right) => right is TypeVariable v && v.Name == Name; | |
} | |
partial record TypeApplication : Type | |
{ | |
public override string? AsVariable() => null; | |
public override bool Match(Type right) | |
=> right is TypeApplication a | |
&& a.Name == Name | |
&& a.Args.Length == Args.Length; | |
} | |
abstract partial record Term : IUnifiable<Term> | |
{ | |
public abstract string? AsVariable(); | |
public abstract bool Match(Term right); | |
} | |
partial record Variable : Term | |
{ | |
public override string? AsVariable() => Name; | |
public override bool Match(Term right) => right is Variable v && v.Name == Name; | |
} | |
partial record Functor : Term | |
{ | |
public override string? AsVariable() => null; | |
public override bool Match(Term right) | |
=> right is Functor f | |
&& f.Atom == Atom | |
&& f.Args.Length == Args.Length; | |
} | |
} |