[Haskell-beginners] what is a qualified type?
Heinrich Apfelmus
apfelmus at quantentunnel.de
Fri Aug 10 13:29:47 CEST 2012
Christopher Howard wrote:
> In short, what is a qualified type and how is it used? (Any examples
> would be appreciated.)
>
> I feel somewhat embarrassed asking, as I used to know. I dropped Haskell
> a while ago and am just now picking it up again, and unfortunately I
> have forgotten many concepts.
>
> If someone could point me to the appropriate tutorial that might be
> enough. For some reason, all my StartPage searches are only bringing me
> to documents that assume I already understand qualified types, or to
> books I can't afford to buy.
This is a type:
[a] -> a
This is a qualified type:
Num a => [a] -> a
You can say that qualified types are types that include constraints via
the => symbol.
In Haskell, you will mostly see type class constraints, but there are
other possibilities as well. They are all grouped together in the notion
of "qualified types".
http://www.haskell.org/haskellwiki/Research_papers/Type_systems#Qualified_types
As a practicing Haskell programmer, you don't actually need to know how
the theory of qualified types works. The only thing you need to be aware
of the expression "ambiguous constraint", because that's an occasional
error message in GHC. Here an example:
Show a => Int -> Bool -- ambiguous constraint
Best regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
More information about the Beginners
mailing list