Data types are blocks or limited area confined for storing some specific item. With respect to programming language, data type of
int type can store 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 to get some prescription for illness that you are suffering with. 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 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 the 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 towards 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 an addition on two data-points: an integer (say 893) and a string (say "programming").
Number data type is hold a numeric number in its value, haskell can infer the type of number. So while writing Number it is not mandatory to mention it's data type explicitly.
For example, If you write 4 + 4, haskell would result 8 like in below image It not just works for integers but alos 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.
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 numeric value in 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 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. Bool keyword is used for characters.
List is nothing but collection of same or different type values stored at a place. A List could store list of list or list of string, list of boolean, list of combinations of 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.
Tuple may contain different type of data inside it.
Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.