Data types are blocks or limited areas confined to storing some specific items. With respect to a programming language, the data type of
int type can store an integer value. If a variable is defined as int then that variable can store only integer values
Imagine the scenario when you go to see a doctor get some prescription for an illness that you are suffering from. Now, the doctor must first identify the disease that you might have and then prescribe the medicines appropriately. He would also, probably, ask for any allergies that you might have and modify the prescription accordingly.
In the case of programming languages, you can consider your body as data, the disease as your data type, the medicines as the operators/functions, or anything that can work on data, and of course you, a programmer, would be the doctor.
Now, on a very basic level, you need to know what type of data are you working on. Without that, it wouldn't be easy and in some cases nigh impossible to determine how to approach a solution.
We can substitute a compiler/interpreter as the doctor as well. In that case, the significance of the exact type of data is even more as the compiler/interpreter must know if the program that is being fed as the input is valid or not.
To be more precise, it must check if the operations that you are trying to perform are compliant with the data type of the data. It doesn't make sense to perform addition on two data-points: an integer (say 893) and a string (say "programming").
The number data type holds a numeric number in its value, Haskell can infer the type of number. So while writing Number it is not mandatory to mention its data type explicitly.
For example, If you write 4 + 4, Haskell would result in 8 like in the below image
It does not just work for integers but also Haskell can infer the data types for point values(decimals).
Integral types contain only whole numbers and not fractions. Int can hold the range from 2147483647 to -2147483647 in Haskell.
An integer is a superset of Int, Integer value is not bounded by any number, so an Integer can be of any length without any limitation.
Float aka Floating point numbers are numbers that have a fractional part, usually represented using two components: the main number and the fractional part, each of which is a binary number. This is known as a floating-point representation.
A double variable can provide precision up to 15 to 16 decimal points as compared to float precision of 6 to 7 decimal digits. Another significant difference between float and double is their storage requirement, double is more expensive than float. It takes 8 bytes to store a variable while float just takes 4 bytes
Character us nothing but a single letter, it could be Alphabet or number or symbol. Haskell can infer a character given in as an input to it.
When you provide a numeric value in a single/Quotation quotation then Haskell tries to convert the numeric value into respective Alphabet using ASCII character.
Char keyword is used for characters.
A string is nothing but a group of characters, There is no specific syntax for using string, but Haskell follows the conventional style of representing a string with a double quotation.
The Boolean data type is a data type that has one of two possible values (usually denoted true and false), intended to represent the two truth values of logic and Boolean algebra. The Bool keyword is used for characters.
The list is nothing but a collection of the same or different type values stored at a place. A-List could store a list of strings, a list of boolean, list of combinations of the same data type.
Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists
A Tuple is an immutable data type, as we cannot modify the number of elements at runtime, whereas a List is a mutable data type. A tuple may contain different types of data inside it.