On Wed, Nov 15, 2006 at 09:04:01AM +0000, Simon Peyton-Jones wrote: > I don't agree. My programs have invariants that I can't always express > in a way that the type system can understand. E.g. I know that a > variable is in scope, so searching for it in an environment can't fail: > head [ v | (n,v) <- env, n==target ] > (Maybe if I had an Oleg implant I could express all this in the type > system -- but I don't.)
Yes, that is sometimes true (though many of the uses of fromJust I see could be easily avoided). The problem is an imbalance of costs. It's so easy to write these things, to the point of discouraging alternatives, but the costs come in debugging and reading. Every time I read code containing these functions, I have to perform a non-local analysis to verify the invariant, or even to determine the invariant. I don't think it's unreasonable to ask the programmer to give some justification, in something like (using Neil's library): headNote "The variable is in scope" [...] That would be extra tagging for the static analysis techniques too. Of course there'd be nothing to stop someone defining head = headNote "I'm all right, Jack" _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe