prettyType :: StructType -> Html
prettyType t = case t of
  Prim et -> primTypeHtml et
  Record fs
    | Just ts <- areTupleFields fs ->
        parens $ commas (map prettyType ts)
    | otherwise ->
        braces $ commas (map ppField $ M.toList fs)
    where ppField (name, tp) =
            toHtml (nameToString name) <> ":" <> prettyType tp
  TypeVar et targs ->
    prettyTypeName et <> foldMap ((<> " ") . prettyTypeArg) targs
  Array arr -> prettyArray arr
prettyType :: StructType -> Html
prettyType t = case t of
  Prim et -> primTypeHtml et
  Record fs
    | Just ts <- areTupleFields fs ->
        parens $ commas (map prettyType ts)
    | otherwise ->
        braces $ commas (map ppField $ M.toList fs)
    where ppField (name, tp) =
            toHtml (nameToString name) <> ":" <> prettyType tp
  TypeVar et targs ->
    prettyTypeName et <> foldMap ((<> " ") . prettyTypeArg) targs
  Array arr -> prettyArray arr
prettyType t = case t of
  Prim et -> primTypeHtml et
  Record fs
    | Just ts <- areTupleFields fs ->
        parens $ commas (map prettyType ts)
    | otherwise ->
        braces $ commas (map ppField $ M.toList fs)
    where ppField (name, tp) =
            toHtml (nameToString name) <> ":" <> prettyType tp
  TypeVar et targs ->
    prettyTypeName et <> foldMap ((<> " ") . prettyTypeArg) targs
  Array arr -> prettyArray arr