Then, if we were to come across some arbitrary sequence of digits which happened to be of type TelephoneNumber we would have access to a lot more information than if it were just a Number – for instance, we could start looking for things such as area and country codes on the initial digits.Īnother reason not to consider the telephone numbers as Numbers is that doing arithmetic with them makes no sense. We might also apply this rationale to the telephone numbers. If we know something is an Address, we instantly know much more about the piece of data – for instance, that we can interpret it using the "human conventions" that give meaning to addresses. Recognizing something as a specialized type is far more meaningful. When we describe something as a String, all that we are saying is that it is a sequence of characters (letters, numbers, etc). In principle, we can indeed say that addresses are Strings, but that doesn't capture many important features of addresses. Each part of the address has its own meaning. If not, then it's probably the name of the house – except if it starts with "PO Box", in which case it's just a postal box address and doesn't indicate where the person lives at all. ![]() For example, if the beginning of the address text contains a number it is likely the number of the house. Many human conventions dictate how we interpret addresses. However, the semantics behind an innocent address are quite complex. ![]() "First Name" and "Last Name" contain text, so we say that the values are of type String.Īt first glance, we might classify address as a String. Let's classify the values in this example in terms of types. Sherlock is a value as is 99 Long Road Street Villestown as well as 655523. For example, say we had a table in a database to store details about a person's contacts a kind of personal telephone book. ![]() We shall adhere to this convention henceforth.ĭatabases illustrate clearly the concept of types. Haskell has a rule that all type names have to begin with a capital letter.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |