on master help sign in
Carry aliases entirely through type inference
53565e2Evan Czaplicki
compiler/Type/State.hs+3−3
@@ -1,7 +1,7 @@
1{-# OPTIONS_GHC -W #-}
1{-# OPTIONS_GHC -W #-}
2module Type.State where
2module Type.State where
3
3
4−import Control.Applicative ((<$>),(<*>), Applicative)
4+import Control.Applicative ( (<$>), (<*>), Applicative, (<|>) )
5import Control.Monad.State
5import Control.Monad.State
6import qualified Data.Map as Map
6import qualified Data.Map as Map
7import qualified Data.Traversable as Traversable
7import qualified Data.Traversable as Traversable
@@ -104,8 +104,8 @@ introduce variable = do
104flatten :: Type -> StateT SolverState IO Variable
104flatten :: Type -> StateT SolverState IO Variable
105flatten term =
105flatten term =
106 case term of
106 case term of
107− VarN alias v -> do
107+ VarN maybeAlias v -> do
108− liftIO $ UF.modifyDescriptor v $ \desc -> desc { alias = alias }
108+ liftIO $ UF.modifyDescriptor v $ \desc -> desc { alias = maybeAlias <|> alias desc }
109 return v
109 return v
110 TermN alias t -> do
110 TermN alias t -> do
111 flatStructure <- traverseTerm flatten t
111 flatStructure <- traverseTerm flatten t