Types Flashcards
How to get type of an expression
using :t operator
How to read :: operator
has type of
Evaluate :t “Hello!”
“Hello!” :: [Char]
what is the meaning of -> in type definitions
it is read as ‘maps’ ; so if Int -> Int is seen in the type declaration, it means this function maps Int parameter to Int result
In case of type definition of a function which are parameters and which is for output
Output type is specified as last item in the list separated by ->
Define Int type
Stands for 32 bit integers, both +ve and -ve
Define Integer type
unbounded integer size
Define Float type
Single precision floating point
Define Double type
Double precision floating point
Define Bool type
type boolean; has only two values True and False
Define Char type
used for single characters. string is a list of chars.
What are polymorphic functions
functions having type variables are called polymorphic
Difference between infix and postfix functions; provide examples
Oeprators are infix functionos, where the operator <param2} is the syntax for intfix functions. These are alled as operatrors as well
Describe ‘Eq’ typeclass
used for types that support equality testing, Members of this type class implement == and /==. If there is a Eq in the type description of a function, it uses in its definition somewhere either == or /== operators
What Haskell functions will not implement ‘Eq’ typeclass
IO functions