@@ -201,9 +201,9 @@ makeCopy alreadyCopiedMark variable =
201201
202202
203203makeCopyHelp :: Descriptor -> Int -> Variable -> Solver Variable
204−makeCopyHelp descriptor alreadyCopiedMark variable =
205− if _mark descriptor == alreadyCopiedMark then
206− case _copy descriptor of
204+makeCopyHelp (Descriptor content rank mark copy) alreadyCopiedMark variable =
205+ if mark == alreadyCopiedMark then
206+ case copy of
207207 Just copiedVariable ->
208208 return copiedVariable
209209
@@ -214,14 +214,14 @@ makeCopyHelp descriptor alreadyCopiedMark variable =
214214 \ with a <http://sscce.org> and information on your OS, how you installed,\
215215 \ and any other configuration information that might be helpful."
216216
217− else if _rank descriptor /= noRank || not (needsCopy (_content descriptor)) then
217+ else if rank /= noRank || not (needsCopy content) then
218218 return variable
219219
220220 else
221221 do pool <- getPool
222222 newVar <-
223223 State.liftIO $ UF.fresh $ Descriptor
224− { _content = error "will be filled in soon!"
224+ { _content = content -- place holder!
225225 , _rank = maxRank pool
226226 , _mark = noMark
227227 , _copy = Nothing
@@ -236,34 +236,37 @@ makeCopyHelp descriptor alreadyCopiedMark variable =
236236 State.liftIO $ UF.modifyDescriptor variable $ \desc ->
237237 desc { _mark = alreadyCopiedMark, _copy = Just newVar }
238238
239+
240+ let setContent newContent =
241+ State.liftIO $ UF.modifyDescriptor newVar $ \desc ->
242+ desc { _content = newContent }
243+
239244 -- Now we recursively copy the content of the variable.
240245 -- We have already marked the variable as copied, so we
241246 -- will not repeat this work or crawl this variable again.
242− let oldContent = _content descriptor
243− newContent <-
244− case oldContent of
245− Structure term ->
246− Structure <$> traverseTerm (makeCopy alreadyCopiedMark) term
247−
248− Atom _ ->
249− return oldContent
247+ case content of
248+ Structure term ->
249+ do newTerm <- traverseTerm (makeCopy alreadyCopiedMark) term
250+ setContent (Structure newTerm)
250251
251− Var Rigid maybeSuper maybeName ->
252− return (Var Flex maybeSuper maybeName)
252+ Atom _ ->
253+ return ()
253254
254− Var Flex _ _ ->
255− return oldContent
255+ Var Rigid maybeSuper maybeName ->
256+ setContent (Var Flex maybeSuper maybeName)
256257
257− Alias name args realType ->
258− Alias name
259− <$> mapM (traverse (makeCopy alreadyCopiedMark)) args
260− <*> makeCopy alreadyCopiedMark realType
258+ Var Flex _ _ ->
259+ return ()
261260
262− Error ->
263− return oldContent
261+ Alias name args realType ->
262+ setContent =<< (
263+ Alias name
264+ <$> mapM (traverse (makeCopy alreadyCopiedMark)) args
265+ <*> makeCopy alreadyCopiedMark realType
266+ )
264267
265− State.liftIO $ UF.modifyDescriptor newVar $ \desc ->
266− desc { _content = newContent }
268+ Error ->
269+ return ()
267270
268271 return newVar
269272