@@ -221,7 +221,7 @@ unifyRigid context maybeSuper maybeName otherContent =
221 rigidityError context maybeName
221 rigidityError context maybeName
223 Var Rigid _ _ ->
223 Var Rigid _ _ ->
224− rigidityError context maybeName
224+ mismatch context (Just Error.DoubleRigid)
226 Atom _ ->
226 Atom _ ->
227 rigidityError context maybeName
227 rigidityError context maybeName
@@ -246,7 +246,7 @@ unifySuper context super otherContent =
246 if atomMatchesSuper super name then
246 if atomMatchesSuper super name then
247 merge context otherContent
247 merge context otherContent
249− mismatch context Nothing
249+ mismatch context (Just (superReason super))
251 Var Rigid Nothing maybeName ->
251 Var Rigid Nothing maybeName ->
252 rigidityError context maybeName
252 rigidityError context maybeName
@@ -297,6 +297,22 @@ combineSupers firstSuper secondSuper =
297 (_ , _ ) -> Nothing
297 (_ , _ ) -> Nothing
300+superReason :: Super -> Error.Reason
300isPrimitiveFrom :: [String] -> Var.Canonical -> Bool
316isPrimitiveFrom :: [String] -> Var.Canonical -> Bool
301isPrimitiveFrom prims var =
317isPrimitiveFrom prims var =
302 any (\p -> Var.isPrim p var) prims
318 any (\p -> Var.isPrim p var) prims
@@ -323,12 +339,12 @@ unifySuperStructure context super term =
323 do appStructure <- liftIO (collectApps (Structure term))
339 do appStructure <- liftIO (collectApps (Structure term))
324 case appStructure of
340 case appStructure of
326− mismatch context Nothing
342+ mismatch context (Just (superReason super))
328 List variable ->
344 List variable ->
329 case super of
345 case super of
330 Number ->
346 Number ->
331− mismatch context Nothing
347+ mismatch context (Just Error.NotNumber)
333 Appendable ->
349 Appendable ->
334 merge context (Structure term)
350 merge context (Structure term)
@@ -344,10 +360,10 @@ unifySuperStructure context super term =
344 Tuple entries ->
360 Tuple entries ->
345 case super of
361 case super of
346 Number ->
362 Number ->
347− mismatch context Nothing
363+ mismatch context (Just Error.NotNumber)
349 Appendable ->
365 Appendable ->
350− mismatch context Nothing
366+ mismatch context (Just Error.NotAppendable)
352 Comparable ->
368 Comparable ->
353 if length entries > 6 then
369 if length entries > 6 then
@@ -358,7 +374,7 @@ unifySuperStructure context super term =
358 mapM_ (unifyComparableRecursive (_orientation context)) entries
374 mapM_ (unifyComparableRecursive (_orientation context)) entries
360 CompAppend ->
376 CompAppend ->
361− mismatch context Nothing
377+ mismatch context (Just Error.NotCompAppend)
364unifyComparableRecursive :: Orientation -> Variable -> Unify ()
380unifyComparableRecursive :: Orientation -> Variable -> Unify ()
@@ -427,7 +443,7 @@ unifyAtom context name otherContent =
427 merge context (Atom name)
443 merge context (Atom name)
430− mismatch context Nothing
446+ mismatch context (Just (superReason super))
432 Var Rigid _ maybeName ->
448 Var Rigid _ maybeName ->
433 rigidityError context maybeName
449 rigidityError context maybeName
@@ -606,28 +622,13 @@ gatherFields context fields variable =
606 Structure (Record1 subFields subExt) ->
622 Structure (Record1 subFields subExt) ->
607 gatherFields context (Map.union fields subFields) subExt
623 gatherFields context (Map.union fields subFields) subExt
609− Structure (EmptyRecord1) ->
625+ Structure EmptyRecord1 ->
610 return (RecordStructure fields variable Empty)
626 return (RecordStructure fields variable Empty)
612− Structure (App1 _ _) ->
613− mismatch context (Just Error.NotRecord)
615− Structure (Fun1 _ _) ->
616− mismatch context (Just Error.NotRecord)
619− mismatch context (Just Error.NotRecord)
622− return (RecordStructure fields variable Extension)
625− mismatch context (Just Error.NotRecord)
627− -- TODO may be dropping useful alias info here
628 Alias _ _ var ->
628 Alias _ _ var ->
629+ -- TODO may be dropping useful alias info here
629 gatherFields context fields var
630 gatherFields context fields var
632 return (RecordStructure fields variable Extension)
633 return (RecordStructure fields variable Extension)