@@ -11,6 +11,7 @@ import qualified Data.Text as Text
11import qualified AST.Module.Name as ModuleName
11import qualified AST.Module.Name as ModuleName
12import qualified Reporting.Annotation as A
12import qualified Reporting.Annotation as A
13import qualified Reporting.Error.Type as Error
13import qualified Reporting.Error.Type as Error
14+import qualified Type.Occurs as Occurs
14import qualified Type.State as TS
15import qualified Type.State as TS
15import Type.Type as Type
16import Type.Type as Type
16import Type.Unify
17import Type.Unify
@@ -268,7 +269,7 @@ crash msg =
268occurs :: (Text.Text, A.Located Variable) -> TS.Solver ()
269occurs :: (Text.Text, A.Located Variable) -> TS.Solver ()
269occurs (name, A.A region variable) =
270occurs (name, A.A region variable) =
270 {-# SCC elm_compiler_type_occurs #-}
271 {-# SCC elm_compiler_type_occurs #-}
271− do hasOccurred <- liftIO $ occursHelp [] variable
272+ do hasOccurred <- liftIO $ Occurs.occurs variable
272 case hasOccurred of
273 case hasOccurred of
274 return ()
275 return ()
@@ -276,44 +277,3 @@ occurs (name, A.A region variable) =
277 do overallType <- liftIO (Type.toSrcType variable)
278 do overallType <- liftIO (Type.toSrcType variable)
278 TS.addError region (Error.InfiniteType name overallType)
279 TS.addError region (Error.InfiniteType name overallType)
281−occursHelp :: [Variable] -> Variable -> IO Bool
282−occursHelp seen var =
283− if elem var seen then
284− do infiniteDescriptor <- UF.descriptor var
285− UF.setDescriptor var (infiniteDescriptor { _content = Error })
289− do desc <- UF.descriptor var
290− case _content desc of
301− -- TODO is it okay to only check args?
302− or <$> mapM (occursHelp (var:seen) . snd) args
306− go = occursHelp (var:seen)
310− (||) <$> go a <*> go b
313− (||) <$> go a <*> go b
318− Record1 fields ext ->
319− or <$> mapM go (ext : Map.elems fields)