[Haskell-cafe] positive Int

Stefan O'Rear stefanor at cox.net
Thu Aug 2 20:49:23 EDT 2007

On Fri, Aug 03, 2007 at 01:45:03AM +0100, Neil Mitchell wrote:
> Hi
> Catch (www.cs.york.ac.uk/~ndm/catch) can infer that certain uses of
> numbers fit into the {Neg, Zero, One, Pos} abstraction - so for
> example it can infer that length returns {Zero, One, Pos}, but not
> Neg. If you then do:
> xs !! length ys
> It will detect that length ys is natural, and will be safe. However,
> if you pass any arbitrary value as the index to !! it will warn of a
> possible pattern match error.

I hope catch doesn't actually think that's safe, because it's not - set
ys = xs = [1,2,3,4,5], you'll get an index out of range error.  (Yes, I
deliberately chose a list longer than 4 elements).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070802/1f3fb573/attachment.bin

More information about the Haskell-Cafe mailing list