[Haskell-cafe] Word rigid in "`a' is a rigid type variable..."

Albert Y. C. Lai trebla at vex.net
Fri Nov 15 22:25:59 UTC 2013


"It could be any type" has always been a truism. It has never been an 
issue of contention. The issue has always been "but who gets to choose". 
Teachers and tutorial writers still don't address that up front and head 
on; they spend 99 minutes harping on "any", watch students fail, and 
finally spend 1 minute to reveal "but you don't choose". As opposed to 
revealing that in the 1st minute so everyone can save the other 99 
minutes. Perhaps they think that it is obvious to themselves, and need 
not be said to students. Perhaps they need to ensure a certain high 
variance in student marks.

Less flexibility for the provider equals more flexibility for the user. 
Less cavalier power for the writer equals more predictive power for the 
reader. Cavalier power has previously been known as convenience, 
flexibility, and expressive power, for the writer; extreme examples 
include self-modifying code and performing list operations on complex 
numbers (let us call that type cavalierism, so that we have a judgmental 
name for the antithesis to type safety); mild examples include type-case 
and allowing effects everywhere. Programming is a dialectic class 
struggle between the user and the provider, between the reader and the 
writer.

Given the type signature

     f :: a -> Bool

and the restriction of "no type-case" and "no effect" such as in 
Haskell, if a simple test results in f () = True, then I know f 5 = 
True, f "hello" = True, universally f x = True. I need just one test 
case, f (), to complement the type. This is from the free theorems that 
Phil Wadler talks about in the article "theorems for free!".

Perhaps f is a useless function. Here is a useful function:

     dpc :: a -> [a]

If a simple test results in dpc () = [(), (), ()], then I know dpc x = 
[x, x, x] universally. replicate 3 is, certainly, a useful function, at 
least for glue code. And it is important to know that I will not be 
trolled by "you get a list of 4 if the type is Double, and you get 
random numbers in the list if the type is Int". The writer's loss of 
cavalier power is my gain of predictive power.

Your freedom is my slavery.
Your ignorance is my strength.
Your war is my peace.

Customers who like this article may also like the following from the 
same author:
http://www.vex.net/~trebla/weblog/any-all-some.html
http://www.vex.net/~trebla/haskell/prerequisite.xhtml#leibniz
and this talk (50 minutes) from another author:
http://www.youtube.com/watch?v=TS1lpKBMkgg


More information about the Haskell-Cafe mailing list