@@ -48,6 +48,8 @@ \subsection{Type classes}
4848\hline
4949\te {NumAlias} & Types which give a new name to a numeric type.\\
5050\hline
51+ \te {StrAlias} & Types which give a new name to a string type.\\
52+ \hline
5153\te {FShow} & Types which can convert a value to a \te {Fmt}
5254representation for use with \te {\$ display} system tasks.\\
5355\hline
@@ -1457,8 +1459,10 @@ \subsubsection{Alias and NumAlias}
14571459\label {sec-alias }
14581460\index {Alias}
14591461\index {NumAlias}
1460- \index [typeclass]{NumAlias }
1462+ \index {StrAlias }
14611463\index [typeclass]{Alias}
1464+ \index [typeclass]{NumAlias}
1465+ \index [typeclass]{StrAlias}
14621466
14631467\te {Alias} specifies that two types can be used interchangeably,
14641468providing a way to introduce local names for types within a module.
@@ -1480,6 +1484,15 @@ \subsubsection{Alias and NumAlias}
14801484endtypeclass
14811485\end {verbatim }
14821486
1487+ \te {StrAlias} is used to give a new name to a string type.
1488+
1489+ \begin {verbatim }
1490+ typeclass StrAlias#(string type a, string type b)
1491+ dependencies (a determines b,
1492+ b determines a);
1493+ endtypeclass
1494+ \end {verbatim }
1495+
14831496{\bf Examples}
14841497\begin {verbatim }
14851498 Alias#(fp, FixedPoint#(i,f));
@@ -4154,7 +4167,7 @@ \subsubsection{Rules}
41544167
41554168
41564169% ================================================================
4157- \subsection {Operations on Numeric Types }
4170+ \subsection {Operations on Numeric and String Types }
41584171
41594172\subsubsection {Size Relationship/Provisos }
41604173
@@ -4338,6 +4351,46 @@ \subsubsection{valueOf and SizeOf pseudo-functions}
43384351 Bit#(SizeOf#(any_type)) = pack(structIn);
43394352\end {libverbatim }
43404353
4354+ % ================================================================
4355+ \subsubsection {String type pseudo-functions }
4356+ \index {stringOf@\texttt {valueOf } (pseudo-function of types)}
4357+ \index {TStrCat@\texttt {TStrCat } (pseudo-function on types)}
4358+ \index {TNumToStr@\texttt {TNumToStr } (pseudo-function on types)}
4359+ \index [function]{Prelude!stringOf}
4360+ \index [function]{Prelude!TStrCat}
4361+ \index [function]{Prelude!TNumToStr}
4362+
4363+ Prelude also provides similar pseudo-functions for string types.
4364+ The pseudo-function \te {stringOf} is used to convert a string type into a \te {String} value.
4365+ The type-level pseudo-function \te {TStrCat} is used to concatenate two string types,
4366+ and \te {TNumToStr} is used to convert a numeric type into a string type.
4367+
4368+ \begin {center }
4369+ \begin {tabular }{|p{1 in}|p{4.6 in}|}
4370+ \hline
4371+ & \\
4372+ \te {stringOf}&Converts a string type into its String value.\\
4373+ \cline {2-2}
4374+ &\begin {libverbatim }
4375+ function String valueOf (t) ;
4376+ \end {libverbatim }
4377+ \\
4378+ \hline
4379+ \end {tabular }
4380+ \end {center }
4381+
4382+ \begin {center }
4383+ \begin {tabular }{|p {1 in}|p{1.5 in}| p{2.0 in}|}
4384+ \hline
4385+ Type Function& Type Relationship& Description\\
4386+ \hline
4387+ \hline
4388+ \te {TStrCat}&\verb 'TStrCat#(s1,s2) '&Concatenate $ s1 $ and $ s2 $ \\
4389+ \hline
4390+ \te {TNumToStr}&\verb 'TNumToStr#(n1) '&Convert numeric type $ n$ to a string type\\
4391+ \hline
4392+ \end {tabular }
4393+ \end {center }
43414394
43424395% ================================================================
43434396\subsection {Registers and Wires }
0 commit comments