@@ -7,13 +7,13 @@ import Control.Monad.Except (ExceptT, lift, liftIO, throwError, runExceptT)
77import qualified Data.Map as Map
88import qualified Data.Maybe as Maybe
99import Data.Text (Text)
10−import qualified Data.UnionFind.IO as UF
1110
1211import qualified AST.Variable as Var
1312import qualified Reporting.Region as R
1413import qualified Reporting.Error.Type as Error
1514import qualified Type.State as TS
1615import Type.Type as Type
16+import qualified Type.UnionFind as UF
1717
1818
1919
@@ -33,7 +33,7 @@ unify hint region expected actual =
3333 mkError =
3434 do expectedSrcType <- Type.toSrcType expected
3535 actualSrcType <- Type.toSrcType actual
36− mergeHelp expected actual Error
36+ mergeHelp expected actual Error noRank
3737 let info = Error.MismatchInfo hint expectedSrcType actualSrcType maybeReason
3838 return (Error.Mismatch info)
3939 in
@@ -147,20 +147,19 @@ errorSuper super =
147147
148148
149149merge :: Context -> Content -> Unify ()
150−merge (Context _ first _ second _) content =
151− liftIO $ mergeHelp first second content
150+merge (Context _ var1 (Descriptor _ rank1 _ _) var2 (Descriptor _ rank2 _ _)) content =
151+ liftIO $ mergeHelp var1 var2 content (min rank1 rank2)
152152
153153
154−mergeHelp :: Variable -> Variable -> Content -> IO ()
155−mergeHelp first second content =
156− UF.union' first second $ \desc1 desc2 ->
157− return $
158− Descriptor
159− { _content = content
160− , _rank = min (_rank desc1) (_rank desc2)
161− , _mark = noMark
162− , _copy = Nothing
163− }
154+mergeHelp :: Variable -> Variable -> Content -> Int -> IO ()
155+mergeHelp var1 second newContent newRank =
156+ UF.union var1 second $
157+ Descriptor
158+ { _content = newContent
159+ , _rank = newRank
160+ , _mark = noMark
161+ , _copy = Nothing
162+ }
164163
165164
166165fresh :: Context -> Content -> Unify Variable
@@ -383,7 +382,7 @@ atomMatchesSuper super name =
383382 Var.isPrim "String" name
384383
385384
386−unifyFlexSuperStructure :: Context -> Super -> Term1 Variable -> Unify ()
385+unifyFlexSuperStructure :: Context -> Super -> FlatType -> Unify ()
387386unifyFlexSuperStructure context super term =
388387 do appStructure <- liftIO (collectApps (Structure term))
389388 case appStructure of
@@ -571,7 +570,7 @@ unifyAlias context name args realVar otherContent =
571570-- UNIFY STRUCTURES
572571
573572
574−unifyStructure :: Context -> Term1 Variable -> Content -> Content -> Unify ()
573+unifyStructure :: Context -> FlatType -> Content -> Content -> Unify ()
575574unifyStructure context term content otherContent =
576575 case otherContent of
577576 Error ->