prettyElem :: RecordArrayElemTypeBase (DimDecl VName) () -> Html
prettyElem e = case e of
  PrimArrayElem bt _ -> primTypeHtml bt
  PolyArrayElem bt targs _ u ->
    prettyU u <> prettyTypeName  bt <> foldMap (" " <>)
    (map prettyTypeArg targs)
  ArrayArrayElem at -> prettyArray at
  RecordArrayElem fs
    | Just ts <- areTupleFields fs
      -> parens $ commas $ map prettyElem ts
    | otherwise
      -> braces . commas $ map ppField $ M.toList fs
    where ppField (name, t) = toHtml (nameToString name) <>
            ":" <> prettyElem t
prettyElem :: RecordArrayElemTypeBase (DimDecl VName) () -> Html
prettyElem e = case e of
  PrimArrayElem bt _ -> primTypeHtml bt
  PolyArrayElem bt targs _ u ->
    prettyU u <> prettyTypeName  bt <> foldMap (" " <>)
    (map prettyTypeArg targs)
  ArrayArrayElem at -> prettyArray at
  RecordArrayElem fs
    | Just ts <- areTupleFields fs
      -> parens $ commas $ map prettyElem ts
    | otherwise
      -> braces . commas $ map ppField $ M.toList fs
    where ppField (name, t) = toHtml (nameToString name) <>
            ":" <> prettyElem t
prettyElem e = case e of
  PrimArrayElem bt _ -> primTypeHtml bt
  PolyArrayElem bt targs _ u ->
    prettyU u <> prettyTypeName  bt <> foldMap (" " <>)
    (map prettyTypeArg targs)
  ArrayArrayElem at -> prettyArray at
  RecordArrayElem fs
    | Just ts <- areTupleFields fs
      -> parens $ commas $ map prettyElem ts
    | otherwise
      -> braces . commas $ map ppField $ M.toList fs
    where ppField (name, t) = toHtml (nameToString name) <>
            ":" <> prettyElem t