@@ -291,7 +291,9 @@ generalize youngMark visitMark youngRank pools =
291291 -- get the ranks right for each entry.
292292 -- start at low ranks so that we only have to pass
293293 -- over the information once.
294− Vector.imapM_ (mapM_ . adjustRank youngMark visitMark) rankTable
294+ Vector.imapM_
295+ (\rank table -> mapM_ (adjustRank youngMark visitMark rank) table)
296+ rankTable
295297
296298 -- For variables that have rank lowerer than youngRank, register them in
297299 -- the appropriate old pool if they are not redundant.
@@ -562,14 +564,13 @@ srcTypeToVar rank pools flexVars srcType =
562564makeCopy :: Int -> Pools -> Variable -> IO Variable
563565makeCopy rank pools var =
564566 do copy <- makeCopyHelp rank pools var
565− _ <- restore var
567+ restore var
566568 return copy
567569
568570
569571makeCopyHelp :: Int -> Pools -> Variable -> IO Variable
570572makeCopyHelp maxRank pools variable =
571− do (Descriptor content rank _ maybeCopy) <-
572− UF.get variable
573+ do (Descriptor content rank _ maybeCopy) <- UF.get variable
573574
574575 case maybeCopy of
575576 Just copy ->
@@ -628,45 +629,65 @@ makeCopyHelp maxRank pools variable =
628629-- RESTORE
629630
630631
631−restore :: Variable -> IO Variable
632+restore :: Variable -> IO ()
632633restore variable =
633− do (Descriptor content _rank _mark maybeCopy) <- UF.get variable
634+ do (Descriptor content _ _ maybeCopy) <- UF.get variable
634635 case maybeCopy of
635636 Nothing ->
636− return variable
637+ return ()
637638
638639 Just _ ->
639− do restoredContent <- restoreContent content
640− UF.set variable $
641− Descriptor restoredContent noRank noMark Nothing
642− return variable
640+ do UF.set variable $ Descriptor content noRank noMark Nothing
641+ restoreContent content
643642
644643
645−restoreContent :: Content -> IO Content
644+restoreContent :: Content -> IO ()
646645restoreContent content =
647646 case content of
648647 FlexVar _ ->
649− return content
648+ return ()
650649
651650 FlexSuper _ _ ->
652− return content
651+ return ()
653652
654653 RigidVar _ ->
655− return content
654+ return ()
656655
657656 RigidSuper _ _ ->
658− return content
657+ return ()
659658
660659 Structure term ->
661− Structure <$> traverseFlatType restore term
660+ case term of
661+ App1 _ _ args ->
662+ mapM_ restore args
662663
663− Alias home name args var ->
664− Alias home name
665− <$> mapM (traverse restore) args
666− <*> restore var
664+ Fun1 arg result ->
665+ do restore arg
666+ restore result
667+
668+ EmptyRecord1 ->
669+ return ()
670+
671+ Record1 fields ext ->
672+ do mapM_ restore fields
673+ restore ext
674+
675+ Unit1 ->
676+ return ()
677+
678+ Tuple1 a b maybeC ->
679+ do restore a
680+ restore b
681+ case maybeC of
682+ Nothing -> return ()
683+ Just c -> restore c
684+
685+ Alias _ _ args var ->
686+ do mapM_ (traverse restore) args
687+ restore var
667688
668689 Error _ ->
669− return content
690+ return ()
670691
671692
672693