@@ -376,10 +376,13 @@ instance Crawl Descriptor where
376376
377377toSrcType :: Variable -> IO T.CanonicalType
378378toSrcType var =
379− do desc <- UF.descriptor =<< addNames var
380− srcType <- maybe (backupSrcType desc) termToSrcType (structure desc)
381− return $ maybe srcType (\name -> T.Aliased name srcType) (alias desc)
379+ go =<< addNames var
382380 where
381+ go v = do
382+ desc <- UF.descriptor v
383+ srcType <- maybe (backupSrcType desc) termToSrcType (structure desc)
384+ return $ maybe srcType (\name -> T.Aliased name srcType) (alias desc)
385+
383386 backupSrcType desc =
384387 case name desc of
385388 Just v@(Var.Canonical _ x@(c:_))
@@ -394,22 +397,22 @@ toSrcType var =
394397 termToSrcType term =
395398 case term of
396399 App1 a b -> do
397− a' <- toSrcType a
398− b' <- toSrcType b
400+ a' <- go a
401+ b' <- go b
399402 case a' of
400403 T.App f args -> return $ T.App f (args ++ [b'])
401404 _ -> return $ T.App a' [b']
402405
403− Fun1 a b -> T.Lambda <$> toSrcType a <*> toSrcType b
406+ Fun1 a b -> T.Lambda <$> go a <*> go b
404407
405− Var1 a -> toSrcType a
408+ Var1 a -> go a
406409
407410 EmptyRecord1 -> return $ T.Record [] Nothing
408411
409412 Record1 tfields extension -> do
410− fields' <- traverse (mapM toSrcType) tfields
413+ fields' <- traverse (mapM go) tfields
411414 let fields = concat [ map ((,) name) ts | (name,ts) <- Map.toList fields' ]
412− ext' <- dealias <$> toSrcType extension
415+ ext' <- dealias <$> go extension
413416 return $ case ext' of
414417 T.Record fs ext -> T.Record (fs ++ fields) ext
415418 T.Var _ -> T.Record fields (Just ext')