Re: Word rigid in "`a' is a rigid type variable..."
Adam Gundry <adam <at> well-typed.com>
2013-11-13 17:52:13 GMT
On 13/11/13 17:24, Vlatko Basic wrote:
> Thanks for explanation. If I understood correctly, 'rigid' refers the
> requirement, not the type itself.
It refers to the type *variable*. This is a standard term  from
unification theory, where variables are divided into two kinds:
* rigid variables, which may not be filled in by the unifier; and
* flexible variables, which may be filled in to solve a constraint.
As Brandon says, a variable in a type declaration means "any type", so
it is rigid. Flexible variables are introduced when you use a
polymorphic definition, and the type inference algorithm must solve for
Sometimes one speaks of a "rigid type", meaning a type that is either
constant (like String) or a rigid variable.
> I think that more intuitive/understandable would be something like
> 'b' has too rigid type for 'a' ...
> At least, that is what I have to tell myself when I encounter this issue
You may well be right that this error message could be easier to
understand, but in suggesting an alternative, be careful to be
consistent with the existing meaning of "rigid".
 Which is to say, I can't remember where it originates.
>> -------- Original Message --------
>> Subject: Re: [Haskell-cafe] Word rigid in "`a' is a rigid type
>> From: Brandon Allbery <allbery.b <at> gmail.com>
>> To: Vlatko Bašić <vlatko.basic <at> gmail.com>
>> Cc: Haskell-Cafe <haskell-cafe <at> haskell.org>
>> Date: 13.11.2013 17:53
>> On Wed, Nov 13, 2013 at 11:37 AM, Vlatko Basic <vlatko.basic <at> gmail.com
>> <mailto: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
>> allbery.b <at> gmail.com <mailto:allbery.b <at> gmail.com>
>> ballbery <at> sinenomine.net <mailto:ballbery <at> sinenomine.net>
>> unix, openafs, kerberos, infrastructure, xmonad
Adam Gundry, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org