Skip to content

Commit a6a5a3e

Browse files
committed
Update docs
1 parent 0c7cab2 commit a6a5a3e

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

doc/BSV_ref_guide/BSV_lang.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,14 +3972,15 @@ \subsection{Type synonyms}
39723972

39733973
\index{Alias}
39743974
\index{NumAlias}
3975+
\index{StrAlias}
39753976

39763977
The \te{typedef} statement must always be at the top level of a
39773978
package, not within a module. To introduce a local name within a
3978-
module, use \te{Alias} or \te{NumAlias} (see \LibRefGuide). Since
3979+
module, use \te{Alias}, \te{NumAlias} or \te{StrAlias} (see \LibRefGuide). Since
39793980
these introduce new names which are type variables as opposed to
39803981
types, the new names must begin with lower case letters.
3981-
\te{NumAlias} is used to give new names to numeric types, while
3982-
\te{Alias} is used for types which can be the types of variables.
3982+
\te{Alias} is used for types which can be the types of variables,
3983+
while \te{NumAlias} and \te{StrAlias} are used to give new names to numeric and string types.
39833984
Example:
39843985

39853986
\begin{verbatim}

doc/libraries_ref_guide/LibDoc/Prelude.tex

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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}
5254
representation 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,
14641468
providing a way to introduce local names for types within a module.
@@ -1480,6 +1484,15 @@ \subsubsection{Alias and NumAlias}
14801484
endtypeclass
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

Comments
 (0)