dwayne/elm-trs2/1.0.0

Logic.Value

Represents all the values (or terms) that can be associated with (logic) variables.

type Value a
= Const a
| Var Variable
| ReifiedVar Int
| Null
| Pair (Value a) (Value a)

It is polymorphic in a so that you can specify your own constants.

type alias ValueS =
    Value String


tea : ValueS
tea =
    Const "tea"

The constant type can be as rich as you need it to be.

Debug

toString : (a -> String) -> Value a -> String

Convert to a representation that's useful for debugging and testing.

u : ValueS
u =
    Var (Variable "u" 0)


r : ValueS
r =
    ReifiedVar 9


toString identity tea == "tea"


toString identity u == "u.0"


toString identity r == "_9"


toString identity Null == "()"


toString identity (Pair tea u) == "(tea . u.0)"


toString identity (Pair tea (Pair u (Pair r Null))) == "(tea u.0 _9)"


toString identity (Pair (Pair tea u) (Pair r Null)) == "((tea . u.0) _9)"