{-# LANGUAGE OverloadedStrings #-} -- | Type definitions module Language.Giml.Syntax.Types where import Data.Data (Data) import Data.Foldable (foldl') import Language.Giml.Common -- | A data type representing kinds. data Kind = Type | KindFun Kind Kind deriving (Int -> Kind -> ShowS [Kind] -> ShowS Kind -> String (Int -> Kind -> ShowS) -> (Kind -> String) -> ([Kind] -> ShowS) -> Show Kind forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Kind] -> ShowS $cshowList :: [Kind] -> ShowS show :: Kind -> String $cshow :: Kind -> String showsPrec :: Int -> Kind -> ShowS $cshowsPrec :: Int -> Kind -> ShowS Show, Kind -> Kind -> Bool (Kind -> Kind -> Bool) -> (Kind -> Kind -> Bool) -> Eq Kind forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Kind -> Kind -> Bool $c/= :: Kind -> Kind -> Bool == :: Kind -> Kind -> Bool $c== :: Kind -> Kind -> Bool Eq, Eq Kind Eq Kind -> (Kind -> Kind -> Ordering) -> (Kind -> Kind -> Bool) -> (Kind -> Kind -> Bool) -> (Kind -> Kind -> Bool) -> (Kind -> Kind -> Bool) -> (Kind -> Kind -> Kind) -> (Kind -> Kind -> Kind) -> Ord Kind Kind -> Kind -> Bool Kind -> Kind -> Ordering Kind -> Kind -> Kind forall a. Eq a -> (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a min :: Kind -> Kind -> Kind $cmin :: Kind -> Kind -> Kind max :: Kind -> Kind -> Kind $cmax :: Kind -> Kind -> Kind >= :: Kind -> Kind -> Bool $c>= :: Kind -> Kind -> Bool > :: Kind -> Kind -> Bool $c> :: Kind -> Kind -> Bool <= :: Kind -> Kind -> Bool $c<= :: Kind -> Kind -> Bool < :: Kind -> Kind -> Bool $c< :: Kind -> Kind -> Bool compare :: Kind -> Kind -> Ordering $ccompare :: Kind -> Kind -> Ordering Ord, Typeable Kind Typeable Kind -> (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Kind -> c Kind) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Kind) -> (Kind -> Constr) -> (Kind -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Kind)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Kind)) -> ((forall b. Data b => b -> b) -> Kind -> Kind) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r) -> (forall u. (forall d. Data d => d -> u) -> Kind -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> Kind -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Kind -> m Kind) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Kind -> m Kind) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Kind -> m Kind) -> Data Kind Kind -> DataType Kind -> Constr (forall b. Data b => b -> b) -> Kind -> Kind forall a. Typeable a -> (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c a) -> (a -> Constr) -> (a -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c a)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)) -> ((forall b. Data b => b -> b) -> a -> a) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall u. (forall d. Data d => d -> u) -> a -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> Data a forall u. Int -> (forall d. Data d => d -> u) -> Kind -> u forall u. (forall d. Data d => d -> u) -> Kind -> [u] forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Kind -> m Kind forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Kind -> m Kind forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Kind forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Kind -> c Kind forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Kind) forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Kind) gmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Kind -> m Kind $cgmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Kind -> m Kind gmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Kind -> m Kind $cgmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Kind -> m Kind gmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Kind -> m Kind $cgmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Kind -> m Kind gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Kind -> u $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Kind -> u gmapQ :: forall u. (forall d. Data d => d -> u) -> Kind -> [u] $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Kind -> [u] gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r $cgmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r gmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r $cgmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Kind -> r gmapT :: (forall b. Data b => b -> b) -> Kind -> Kind $cgmapT :: (forall b. Data b => b -> b) -> Kind -> Kind dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Kind) $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Kind) dataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Kind) $cdataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Kind) dataTypeOf :: Kind -> DataType $cdataTypeOf :: Kind -> DataType toConstr :: Kind -> Constr $ctoConstr :: Kind -> Constr gunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Kind $cgunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Kind gfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Kind -> c Kind $cgfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Kind -> c Kind Data) -- | A data type representing types. data Type = -- | type variables, like @a@ TypeVar TypeVar | -- | type constructors, like @List@ and @Int@ TypeCon TypeCon | -- | type application, like @List a@ TypeApp Type Type | -- | the type of a record, like @{ x : Int, y : String }@ TypeRec [(Label, Type)] | -- | a record with an extension, such as @{ x : Int, y : String | r }@, -- means "this record has at least @{ x : Int, y : String }@, but can have more fields" TypeRecExt [(Label, Type)] TypeVar | -- | the type of a closed variant, such as @[ Some : Int | Nil : {} ]@, -- the value can be one of the constructors. TypeVariant [(Constr, Type)] | -- | the type of a lower bounded polymorphic variant, such as @[a> Some : Int | Nil : {} ]@, -- the value can be at least one of the constructors or potentially more. TypePolyVariantLB [(Constr, Type)] TypeVar | -- | the type of a upper bounded polymorphic variant, such as @[a< Some : Int | Nil : {} ]@, -- the value can be at most one of the constructors or potentially less. -- -- The type variable here is special and is used to track the information of -- which variants we already know of during the type inference process. TypePolyVariantUB TypeVar [(Constr, Type)] | -- | A generalized type which closes over all of its type variables, -- such as @forall a b. a -> b -> a@ TypeScheme [TypeVar] Type deriving (Int -> Type -> ShowS [Type] -> ShowS Type -> String (Int -> Type -> ShowS) -> (Type -> String) -> ([Type] -> ShowS) -> Show Type forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Type] -> ShowS $cshowList :: [Type] -> ShowS show :: Type -> String $cshow :: Type -> String showsPrec :: Int -> Type -> ShowS $cshowsPrec :: Int -> Type -> ShowS Show, Type -> Type -> Bool (Type -> Type -> Bool) -> (Type -> Type -> Bool) -> Eq Type forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Type -> Type -> Bool $c/= :: Type -> Type -> Bool == :: Type -> Type -> Bool $c== :: Type -> Type -> Bool Eq, Eq Type Eq Type -> (Type -> Type -> Ordering) -> (Type -> Type -> Bool) -> (Type -> Type -> Bool) -> (Type -> Type -> Bool) -> (Type -> Type -> Bool) -> (Type -> Type -> Type) -> (Type -> Type -> Type) -> Ord Type Type -> Type -> Bool Type -> Type -> Ordering Type -> Type -> Type forall a. Eq a -> (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a min :: Type -> Type -> Type $cmin :: Type -> Type -> Type max :: Type -> Type -> Type $cmax :: Type -> Type -> Type >= :: Type -> Type -> Bool $c>= :: Type -> Type -> Bool > :: Type -> Type -> Bool $c> :: Type -> Type -> Bool <= :: Type -> Type -> Bool $c<= :: Type -> Type -> Bool < :: Type -> Type -> Bool $c< :: Type -> Type -> Bool compare :: Type -> Type -> Ordering $ccompare :: Type -> Type -> Ordering Ord, Typeable Type Typeable Type -> (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type) -> (Type -> Constr) -> (Type -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type)) -> ((forall b. Data b => b -> b) -> Type -> Type) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r) -> (forall u. (forall d. Data d => d -> u) -> Type -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> Type -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Type -> m Type) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type) -> Data Type Type -> DataType Type -> Constr (forall b. Data b => b -> b) -> Type -> Type forall a. Typeable a -> (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c a) -> (a -> Constr) -> (a -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c a)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)) -> ((forall b. Data b => b -> b) -> a -> a) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r) -> (forall u. (forall d. Data d => d -> u) -> a -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> a -> m a) -> Data a forall u. Int -> (forall d. Data d => d -> u) -> Type -> u forall u. (forall d. Data d => d -> u) -> Type -> [u] forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Type -> m Type forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) gmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type $cgmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type gmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type $cgmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Type -> m Type gmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Type -> m Type $cgmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Type -> m Type gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Type -> u $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Type -> u gmapQ :: forall u. (forall d. Data d => d -> u) -> Type -> [u] $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Type -> [u] gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r $cgmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r gmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r $cgmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Type -> r gmapT :: (forall b. Data b => b -> b) -> Type -> Type $cgmapT :: (forall b. Data b => b -> b) -> Type -> Type dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Type) dataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) $cdataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Type) dataTypeOf :: Type -> DataType $cdataTypeOf :: Type -> DataType toConstr :: Type -> Constr $ctoConstr :: Type -> Constr gunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type $cgunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Type gfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type $cgfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Type -> c Type Data) typeFun :: [Type] -> Type -> Type typeFun :: [Type] -> Type -> Type typeFun [Type] argsT Type retT = (Type -> Type -> Type) -> Type -> [Type] -> Type forall (t :: * -> *) a b. Foldable t => (a -> b -> b) -> b -> t a -> b foldr (\Type i Type o -> Type -> Type -> Type TypeApp (Type -> Type -> Type TypeApp (TypeCon -> Type TypeCon TypeCon "->") Type i) Type o) Type retT [Type] argsT typeApp :: Type -> [Type] -> Type typeApp :: Type -> [Type] -> Type typeApp = (Type -> Type -> Type) -> Type -> [Type] -> Type forall (t :: * -> *) b a. Foldable t => (b -> a -> b) -> b -> t a -> b foldl' Type -> Type -> Type TypeApp toTypeFun :: Type -> ([Type], Type) toTypeFun :: Type -> ([Type], Type) toTypeFun = \case TypeApp (TypeApp (TypeCon TypeCon "->") Type i) Type o -> let ([Type] f, Type r) = Type -> ([Type], Type) toTypeFun Type o in (Type i Type -> [Type] -> [Type] forall a. a -> [a] -> [a] : [Type] f, Type r) Type other -> ([], Type other) overTypes :: (Monad m) => (Type -> m Type) -> Type -> m Type overTypes :: forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f = \case TypeRec [(Label, Type)] record -> do [(Label, Type)] r <- ((Label, Type) -> m (Label, Type)) -> [(Label, Type)] -> m [(Label, Type)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Label, Type) -> m (Label, Type) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Label, Type) -> m (Label, Type)) -> (Type -> m Type) -> (Label, Type) -> m (Label, Type) forall a b. (a -> b) -> a -> b $ (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f) [(Label, Type)] record Type -> m Type f ([(Label, Type)] -> Type TypeRec [(Label, Type)] r) TypeRecExt [(Label, Type)] record TypeVar ext -> do [(Label, Type)] r <- ((Label, Type) -> m (Label, Type)) -> [(Label, Type)] -> m [(Label, Type)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Label, Type) -> m (Label, Type) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Label, Type) -> m (Label, Type)) -> (Type -> m Type) -> (Label, Type) -> m (Label, Type) forall a b. (a -> b) -> a -> b $ (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f) [(Label, Type)] record Type -> m Type f ([(Label, Type)] -> TypeVar -> Type TypeRecExt [(Label, Type)] r TypeVar ext) TypeVariant [(Constr, Type)] vars -> do [(Constr, Type)] vars' <- ((Constr, Type) -> m (Constr, Type)) -> [(Constr, Type)] -> m [(Constr, Type)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Constr, Type) -> m (Constr, Type) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Constr, Type) -> m (Constr, Type)) -> (Type -> m Type) -> (Constr, Type) -> m (Constr, Type) forall a b. (a -> b) -> a -> b $ (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f) [(Constr, Type)] vars Type -> m Type f ([(Constr, Type)] -> Type TypeVariant [(Constr, Type)] vars') TypePolyVariantUB TypeVar tv [(Constr, Type)] vars -> do [(Constr, Type)] vars' <- ((Constr, Type) -> m (Constr, Type)) -> [(Constr, Type)] -> m [(Constr, Type)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Constr, Type) -> m (Constr, Type) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Constr, Type) -> m (Constr, Type)) -> (Type -> m Type) -> (Constr, Type) -> m (Constr, Type) forall a b. (a -> b) -> a -> b $ (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f) [(Constr, Type)] vars Type -> m Type f (TypeVar -> [(Constr, Type)] -> Type TypePolyVariantUB TypeVar tv [(Constr, Type)] vars') TypePolyVariantLB [(Constr, Type)] vars TypeVar tv -> do [(Constr, Type)] vars' <- ((Constr, Type) -> m (Constr, Type)) -> [(Constr, Type)] -> m [(Constr, Type)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Constr, Type) -> m (Constr, Type) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse ((Type -> m Type) -> (Constr, Type) -> m (Constr, Type)) -> (Type -> m Type) -> (Constr, Type) -> m (Constr, Type) forall a b. (a -> b) -> a -> b $ (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f) [(Constr, Type)] vars Type -> m Type f ([(Constr, Type)] -> TypeVar -> Type TypePolyVariantLB [(Constr, Type)] vars' TypeVar tv) TypeScheme [TypeVar] vars Type typ -> do Type inner <- [TypeVar] -> Type -> Type TypeScheme [TypeVar] vars (Type -> Type) -> m Type -> m Type forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f Type typ Type -> m Type f Type inner TypeApp Type t1 Type t2 -> do Type inner <- Type -> Type -> Type TypeApp (Type -> Type -> Type) -> m Type -> m (Type -> Type) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f Type t1 m (Type -> Type) -> m Type -> m Type forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> (Type -> m Type) -> Type -> m Type forall (m :: * -> *). Monad m => (Type -> m Type) -> Type -> m Type overTypes Type -> m Type f Type t2 Type -> m Type f Type inner TypeVar TypeVar var -> Type -> m Type f (TypeVar -> Type TypeVar TypeVar var) TypeCon TypeCon con -> Type -> m Type f (TypeCon -> Type TypeCon TypeCon con)