Polishing the boilerplate: a dis-unsafely safe cast

2003-03-24 Thread oleg
Hello! The paper http://research.microsoft.com/~simonpj/papers/hmap/ by Ralf Laemmel and Simon Peyton Jones gave a reference implementation of a 'cast' function. Here's another implementation: cast:: (Show a, Read b) = a - Maybe b cast = read_as . show where read_as s =

Re: Polishing the boilerplate: a dis-unsafely safe cast

2003-03-24 Thread Hal Daume III
This is getting off-topic, but... I don't like this solution at all :). It is very dependent on read being a true inverse of show, which isn't always the case. Perhaps more importantly though, I don't like the fact that it will readily convert between Int and Float, etc. For instance, in