[Haskell-beginners] Type of function or type of the output of function?

divyanshu ranjan idivyanshu.ranjan at gmail.com
Sat Dec 8 10:28:12 CET 2012


Hi,

The second one looks like :t return the type of function (Num a, Ord a) =>
> [a]


(Num a, Ord a) => [a] is not function, First part is type constraints.




On Sat, Dec 8, 2012 at 2:41 PM, Trung Quang Nguyen <trungnq97 at gmail.com>wrote:

> Hi there,
>
> I have a quickSort implementation, then I try to use :t in ghci to inspect
> what type I receive. I got this.
>
> *Main> :t quickSort "Hello the world"
> quickSort "Hello the world" :: [Char]
> *Main> :t quickSort [3,2, 1,-10]
> quickSort [3,2, 1,-10] :: (Num a, Ord a) => [a]
>
> The first one looks like :t return type of output of quickSort [Char]
>
> The second one looks like :t return the type of function (Num a, Ord a) =>
> [a]
>
> Anybody know why this happens? When we will receive type of output, or
> type of function? And why (Num a, Ord a) => [a], even quickSort doesn't
> have explicit type, so this type comes from input type and type of function
> is defined in runtime?
>
> Thanks a lot!
>
> Cheers,
> Trung
>
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121208/66d47035/attachment-0001.htm>


More information about the Beginners mailing list