- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/intro.tex
rc1c0efdb r29c8675 61 61 The alias names are constants, which follow transitively from their binding to other constants. 62 62 \item 63 Defines a type for generating instan ts (variables).63 Defines a type for generating instances (variables). 64 64 \item 65 65 For safety, an enumeration instance should be restricted to hold only its constant names. … … 232 232 % https://hackage.haskell.org/package/base-4.19.1.0/docs/GHC-Enum.html 233 233 234 The association between ADT and enumeration occurs if all the constructors have a unit (empty) type, \eg @struct unit {}@. 235 Note, the unit type is not the same as \lstinline{void}. 236 \begin{cfa} 237 void foo( void ); 238 struct unit {} u; $\C[1.5in]{// empty type}$ 239 unit bar( unit ); 240 foo( @foo()@ ); $\C{// void argument does not match with void parameter}$ 241 bar( bar( u ) ); $\C{// unit argument does match with unit parameter}\CRT$ 242 \end{cfa} 234 % The association between ADT and enumeration occurs if all the constructors have a unit (empty) type, \eg @struct unit {}@. 235 % Note, the unit type is not the same as \lstinline{void}. 236 In terms of functional programming linguistics, enumerations often refers to a @unit type@ ADT, where @unit type@ is a type 237 that carry no information. 238 % \begin{cfa} 239 % void foo( void ); 240 % struct unit {} u; $\C[1.5in]{// empty type}$ 241 % unit bar( unit ); 242 % foo( @foo()@ ); $\C{// void argument does not match with void parameter}$ 243 % bar( bar( u ) ); $\C{// unit argument does match with unit parameter}\CRT$ 244 % \end{cfa} 243 245 244 246 For example, in the Haskell ADT:
Note: See TracChangeset
for help on using the changeset viewer.