inlineS env stack ty@(TcCon tc _ targs) = do
  s <- get
  -- This needs to be checked first, to treat correctly
  -- references to the root type we are inlining.
  if tc `Set.member` _noInline s then return $ always (DPLeaf ty)
  -- An attempt at unfolding of a recursive type has been detected.
  -- Unwind back the the previous call on that type.
  else if tc `Set.member` stack then throwError tc
  else do
    let stack' = Set.insert tc stack
    catchError (inlineS' env stack' tc targs) $ \ tc' ->
      if tc == tc' then do
        noInline %= Set.insert tc
        return $ always (DPLeaf ty)
      else throwError tc'
inlineS env stack ty@(TcCon tc _ targs) = do
  s <- get
  -- This needs to be checked first, to treat correctly
  -- references to the root type we are inlining.
  if tc `Set.member` _noInline s then return $ always (DPLeaf ty)
  -- An attempt at unfolding of a recursive type has been detected.
  -- Unwind back the the previous call on that type.
  else if tc `Set.member` stack then throwError tc
  else do
    let stack' = Set.insert tc stack
    catchError (inlineS' env stack' tc targs) $ \ tc' ->
      if tc == tc' then do
        noInline %= Set.insert tc
        return $ always (DPLeaf ty)
      else throwError tc'
inlineS env stack ty@(TcCon tc _ targs) = do
  s <- get
  -- This needs to be checked first, to treat correctly
  -- references to the root type we are inlining.
  if tc `Set.member` _noInline s then return $ always (DPLeaf ty)
  -- An attempt at unfolding of a recursive type has been detected.
  -- Unwind back the the previous call on that type.
  else if tc `Set.member` stack then throwError tc
  else do
    let stack' = Set.insert tc stack
    catchError (inlineS' env stack' tc targs) $ \ tc' ->
      if tc == tc' then do
        noInline %= Set.insert tc
        return $ always (DPLeaf ty)
      else throwError tc'