What is data type

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").


Numbers

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 haskell-number-type-variables It not just works for integers but alos haskell can infer the data types for point values(decimals). haskell-numbers-float

Int :

Integral types contain only whole numbers and not fractions.. Int can hold the range from 2147483647 to -2147483647 in haskell.


Integer :

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 :

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.


Double :

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


Characters in Haskell

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.



String

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.



Boolean

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 in Haskell

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


Tuple

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.



About Author

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.

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Recent Addition

new tutorial Protractor Online Training : I am starting online training course for Protractor with Typescript from 15th November 2018.

You can attend first 3 classes for free, the total course fee is INR 10,000

The course time would be 8.00 PM(IST) for the first three classes

The course time would be 8.00 PM(IST) for the first three classes

If you are interested to learn then you can join the course by sending email to chercher.tech@gmail.com

or Register below


Subscribe
 
Join My Facebook Group
Join Group