swarm-0.5.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Language.Typecheck.Unify

Description

Utilities related to type unification.

Synopsis

Documentation

data UnifyStatus Source #

The result of doing a unification check on two types.

Constructors

Apart

The two types are definitely not equal; they will never unify no matter how any unification variables get filled in. For example, (int * u0) and (u1 -> u2) are apart: the first is a product type and the second is a function type.

MightUnify

The two types might unify, depending on how unification variables get filled in, but we're not sure. For example, (int * u0) and (u1 * bool).

Equal

The two types are most definitely equal, and we don't need to bother generating a constraint to make them so. For example, (int * text) and (int * text).

Instances

Instances details
Monoid UnifyStatus Source # 
Instance details

Defined in Swarm.Language.Typecheck.Unify

Semigroup UnifyStatus Source #

The Semigroup instance for UnifyStatus is used to combine results for compound types.

Instance details

Defined in Swarm.Language.Typecheck.Unify

Read UnifyStatus Source # 
Instance details

Defined in Swarm.Language.Typecheck.Unify

Show UnifyStatus Source # 
Instance details

Defined in Swarm.Language.Typecheck.Unify

Eq UnifyStatus Source # 
Instance details

Defined in Swarm.Language.Typecheck.Unify

Ord UnifyStatus Source # 
Instance details

Defined in Swarm.Language.Typecheck.Unify

unifyCheck :: UType -> UType -> UnifyStatus Source #

Given two types, try hard to prove either that (1) they are Apart, i.e. cannot possibly unify, or (2) they are definitely Equal. In case (1), we can generate a much better error message at the instant the two types come together than we could if we threw a constraint into the unifier. In case (2), we don't have to bother with generating a trivial constraint. If we don't know for sure whether they will unify, return MightUnify.