Add a useful helper function to the instantiation state

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2023-11-26 00:44:43 -08:00
parent b13cdea15d
commit 7d78db96d6

View File

@ -1,4 +1,9 @@
module Bergamot.Syntax exposing (Term(..), instantiate, emptyInstantiationState, unify, emptyUnificationState, reify)
module Bergamot.Syntax exposing
( Term(..), Metavariable, UnificationVar
, instantiate, instantiateList, InstantiationState, emptyInstantiationState, resetVars
, unify, unifyList, UnificationState, emptyUnificationState
, reify
)
import Set exposing (Set)
import Dict exposing (Dict)
@ -23,6 +28,9 @@ type alias InstantiationState =
emptyInstantiationState = { counter = 0, vars = Dict.empty }
resetVars : InstantiationState -> InstantiationState
resetVars is = { is | vars = Dict.empty }
metavariable : Metavariable -> InstantiationState -> (UnificationVar, InstantiationState)
metavariable mv is =
case Dict.get mv is.vars of