inlineBaseS' :: (Ord c, Ord tc, Ord tv)
  => TcEnv v c tc tv -> Set tc -> tc -> [Type tc tv]
  -> BaseInliner c tc tv (TypeRank, [(Weight, DataPat c tc tv)])
inlineBaseS' env stack tc targs = do
  if tc `Set.member` stack
  then return (Cyclic, [])
  else do
    r@(rk, alts) <- inlineBaseTcS env stack tc
    case rk of
      Simple -> return r
      Cyclic -> return (Cyclic, [])
      DependsVar -> do
        let (vs, _) = tyConEnv env Map.! tc
            sub = mkSub vs targs
        (filterSimplest <$>) . forM alts $ \(w, alt) ->
          (scaleWeights w <$>) <$> inlineBaseDataS env stack sub alt

-- | Unfold holes in a partial value.
inlineBaseS' :: (Ord c, Ord tc, Ord tv)
  => TcEnv v c tc tv -> Set tc -> tc -> [Type tc tv]
  -> BaseInliner c tc tv (TypeRank, [(Weight, DataPat c tc tv)])
inlineBaseS' env stack tc targs = do
  if tc `Set.member` stack
  then return (Cyclic, [])
  else do
    r@(rk, alts) <- inlineBaseTcS env stack tc
    case rk of
      Simple -> return r
      Cyclic -> return (Cyclic, [])
      DependsVar -> do
        let (vs, _) = tyConEnv env Map.! tc
            sub = mkSub vs targs
        (filterSimplest <$>) . forM alts $ \(w, alt) ->
          (scaleWeights w <$>) <$> inlineBaseDataS env stack sub alt

-- | Unfold holes in a partial value.
inlineBaseS' env stack tc targs = do
  if tc `Set.member` stack
  then return (Cyclic, [])
  else do
    r@(rk, alts) <- inlineBaseTcS env stack tc
    case rk of
      Simple -> return r
      Cyclic -> return (Cyclic, [])
      DependsVar -> do
        let (vs, _) = tyConEnv env Map.! tc
            sub = mkSub vs targs
        (filterSimplest <$>) . forM alts $ \(w, alt) ->
          (scaleWeights w <$>) <$> inlineBaseDataS env stack sub alt

-- | Unfold holes in a partial value.