Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Data.Word in Haskell called that?

Tags:

haskell

Why is an unsigned integral type in Haskell called "Word"? Does the "ord" stand for "ordinal"?

Here is the documentation on Data.Word: http://hackage.haskell.org/package/base-4.6.0.1/docs/Data-Word.html#t:Word

This is a very hard question to google!

like image 336
apolune Avatar asked Mar 20 '14 20:03

apolune


People also ask

What is word in Haskell?

Overview. The words function in Haskell is a built-in function that takes a String and separates it by whitespace characters.

What does () mean in Haskell?

() is very often used as the result of something that has no interesting result. For example, an IO action that is supposed to perform some I/O and terminate without producing a result will typically have type IO () .


1 Answers

From wikipedia:

The term 'word' is used for a small group of bits which are handled simultaneously by processors of a particular architecture. The size of a word is thus CPU-specific. Many different word sizes have been used, including 6-, 8-, 12-, 16-, 18-, 24-, 32-, 36-, 39-, 48-, 60-, and 64-bit. Since it is architectural, the size of a word is usually set by the first CPU in a family, rather than the characteristics of a later compatible CPU. The meanings of terms derived from word, such as longword, doubleword, quadword, and halfword, also vary with the CPU and OS.

In short, a word is a fixed-length group of bits that the CPU can process. We normally work with words that are powers of two, since modern CPUs handle those very well. A word in particular is not really a number, although we treat it as such for most purposes. Instead, just think of it as a fixed number of bits in RAM that you can manipulate. A common use for something like Word8 is to implement ASCII C-style strings, for example. Haskell's implementation treats WordN types as unsigned integers that implement Num, among other type classes.


There is a module called Data.Ord where "Ord" stands for "Ordering". It has extra functions for working with comparisons of datatypes and is where the Ordering datatype and Ord typeclass are defined. It is unrelated to Data.Word.

like image 156
bheklilr Avatar answered Nov 12 '22 16:11

bheklilr