[Haskell-cafe] Word rigid in "`a' is a rigid type variable..."
Brandon Allbery
allbery.b at gmail.com
Wed Nov 13 16:53:03 UTC 2013
On Wed, Nov 13, 2013 at 11:37 AM, Vlatko Basic <vlatko.basic at gmail.com>wrote:
> f :: a -> Bool
> f a = let b = "x" in a == b
>
> compiler complains with
> `a' is a rigid type variable bound by the type signature for f :: a ->
> Bool
>
> I'm puzzled with the choice of word 'rigid' here.
> I see these types as
> - 'b' has "rigid/unchangeable" type (only String), and
> - 'a' has "soft/variable" type (any type, no constraints).
>
The type declaration is the final arbiter. Since it says "any type", it
means exactly that: you are claiming your function is prepared to handle
*any type* the caller wishes to specify. It is not "soft", nor "variable"
in the sense you intend: it is a hard requirement that your function must
be prepared to handle whatever type the caller wants there.
But instead your function requires that it be String, because both sides of
(==) must be the same type. This violates the type signature'a assertion
that the caller can specify any type.
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131113/893f2289/attachment.html>
More information about the Haskell-Cafe
mailing list