# Declaration order of aliases and type families

## Summary

I don't fully understand what's going on, but...

Sometimes if an alias is defined in a module after a type family is introduced, and the alias used in a type instance, then strange things can happen in the body of the type instance.

## Steps to reproduce

I have the following extensions on:

```
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
```

I have the following two type families:

```
type family ToKind (b :: Bool) :: Type
type family ToType (b :: Bool) :: ToKind b
```

An alias such as:

`type TRUE = 'True`

Along with instances such as:

```
type instance ToKind TRUE = Type -> Type
type instance ToType TRUE = Maybe
```

If I define the `TRUE`

alias beneath the `ToType`

type family, then I get errors.

But if I define it first, everything is okay!

Here are the different arrangements and if they compile or not:

```
-- Alias then type family - compiles
type TRUE = 'True
type family ToType (b :: Bool) :: ToKind b
```

```
-- Type family then alias - fails:
-- Expecting one more argument to ‘Maybe’
-- Expected kind ‘ToKind TRUE’, but ‘Maybe’ has kind ‘* -> *’
-- In the type ‘Maybe’
-- In the type instance declaration for ‘ToType’
type family ToType (b :: Bool) :: ToKind b
type TRUE = 'True
```

## Expected behavior

I would expect no errors in this case.

## Environment

- GHC version used: 9.2.1, 9.0.1, 8.10.7, 8.8.4