is a numeral without a decimal point
for example 0
, 1
, 42
, ...
is implicitly applied to fromInteger
which is part of the Num
type class so it indeed has type Num a => a
- that is it can have any type that is an instance of Num
is a numeral with a decimal point
for example 0.0
, -0.1111
, ...
is implicitly applied to fromRational
which is part of the Fractional
type class so it indeed has type a => a
- that is it can have any type that is an instance of Fractional
If you add the language extension OverloadedStrings
to GHC you can have the same for String
-literals which then are applied to fromString
from the Data.String.IsString
type class
This is often used to replace String
with Text
or ByteString
.
Lists can defined with the [1, 2, 3]
literal syntax. In GHC 7.8 and beyond, this can also be used to define other list-like structures with the OverloadedLists
extension.
By default, the type of []
is:
> :t []
[] :: [t]
With OverloadedLists
, this becomes:
[] :: GHC.Exts.IsList l => l