@@ -48,6 +48,8 @@ \subsection{Type classes}
48
48
\hline
49
49
\te {NumAlias} & Types which give a new name to a numeric type.\\
50
50
\hline
51
+ \te {StrAlias} & Types which give a new name to a string type.\\
52
+ \hline
51
53
\te {FShow} & Types which can convert a value to a \te {Fmt}
52
54
representation for use with \te {\$ display} system tasks.\\
53
55
\hline
@@ -1457,8 +1459,10 @@ \subsubsection{Alias and NumAlias}
1457
1459
\label {sec-alias }
1458
1460
\index {Alias}
1459
1461
\index {NumAlias}
1460
- \index [typeclass]{NumAlias }
1462
+ \index {StrAlias }
1461
1463
\index [typeclass]{Alias}
1464
+ \index [typeclass]{NumAlias}
1465
+ \index [typeclass]{StrAlias}
1462
1466
1463
1467
\te {Alias} specifies that two types can be used interchangeably,
1464
1468
providing a way to introduce local names for types within a module.
@@ -1480,6 +1484,15 @@ \subsubsection{Alias and NumAlias}
1480
1484
endtypeclass
1481
1485
\end {verbatim }
1482
1486
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
+
1483
1496
{\bf Examples}
1484
1497
\begin {verbatim }
1485
1498
Alias#(fp, FixedPoint#(i,f));
@@ -4154,7 +4167,7 @@ \subsubsection{Rules}
4154
4167
4155
4168
4156
4169
% ================================================================
4157
- \subsection {Operations on Numeric Types }
4170
+ \subsection {Operations on Numeric and String Types }
4158
4171
4159
4172
\subsubsection {Size Relationship/Provisos }
4160
4173
@@ -4338,6 +4351,46 @@ \subsubsection{valueOf and SizeOf pseudo-functions}
4338
4351
Bit#(SizeOf#(any_type)) = pack(structIn);
4339
4352
\end {libverbatim }
4340
4353
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 stringOf (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#(n) '&Convert numeric type $ n$ to a string type\\
4391
+ \hline
4392
+ \end {tabular }
4393
+ \end {center }
4341
4394
4342
4395
% ================================================================
4343
4396
\subsection {Registers and Wires }
0 commit comments