@@ -7,6 +7,8 @@ import qualified Type.State as TS
7import Control.Arrow (first,second)
7import Control.Arrow (first,second)
8import Control.Monad.State
8import Control.Monad.State
9import SourceSyntax.Location
9import SourceSyntax.Location
10+import Type.PrettyPrint
11+import Text.PrettyPrint (render)
11unify :: SrcSpan -> Variable -> Variable -> StateT TS.SolverState IO ()
13unify :: SrcSpan -> Variable -> Variable -> StateT TS.SolverState IO ()
12unify span variable1 variable2 = do
14unify span variable1 variable2 = do
@@ -106,6 +108,12 @@ actuallyUnify span variable1 variable2 = do
106 List _ -> flexAndUnify varSuper
108 List _ -> flexAndUnify varSuper
107 _ -> comparableError ""
109 _ -> comparableError ""
111+ rigidError variable = TS.addError span msg variable1 variable2
114+ [ "Cannot unify rigid type variable '", render (pretty Never variable), "'.\n"
115+ , "It is likely that a type annotation is not general enough." ]
109 superUnify =
117 superUnify =
110 case (flex desc1, flex desc2, name desc1, name desc2) of
118 case (flex desc1, flex desc2, name desc1, name desc2) of
111 (Is super1, Is super2, _, _)
119 (Is super1, Is super2, _, _)
@@ -126,6 +134,8 @@ actuallyUnify span variable1 variable2 = do
126 (Is Appendable, _, _, _) -> unifyAppendable variable1 variable2
134 (Is Appendable, _, _, _) -> unifyAppendable variable1 variable2
127 (_, Is Appendable, _, _) -> unifyAppendable variable2 variable1
135 (_, Is Appendable, _, _) -> unifyAppendable variable2 variable1
137+ (Rigid, _, _, _) -> rigidError variable1
138+ (_, Rigid, _, _) -> rigidError variable2
129 _ -> TS.addError span "" variable1 variable2
139 _ -> TS.addError span "" variable1 variable2
131 case (structure desc1, structure desc2) of
141 case (structure desc1, structure desc2) of