unique-logic-tf-0.5.1: Solve simple simultaneous equations

Safe HaskellSafe
LanguageHaskell98

UniqueLogic.ST.TF.Example.Incremental

Description

Warning: This module is intended for documentation purposes. Do not import it!

We have a set of variables and equality relations between them. We want to assign a distinct number to each group of equal variables. Eventually every variable shall carry its group identifier.

We solve this by an incremental solution. For every variable we query its identifier. If it is still unset we discovered a new group. In this case we generate a new identifier and solve the system (again) with an additional equality constraint with respect to the new identifier.

In general it is not a good idea to solve a system incrementally, because earlier assignments cannot trigger later added assignments. In this example it works because we add assignments from constants, that is, we add only new trigger seeds.

Synopsis

Documentation

example :: [Int] Source #

a=c
d=f
c=e
b

Groups: {a,c,e}, {d,f}, {b}

Incremental> example
[0,1,0,2,0,2]