Hello Henning, Wednesday, April 8, 2009, 1:43:31 AM, you wrote:
> i is Integer, so asTypeOf is not so easy to apply. I propose to write safeFromInteger i = let mb = maxBound in if i > (toInteger mb) then Nothing else Just (fromInteger i `asTypeOf` mb) or you can do it opposite way: safeFromInteger i = let res = fromInteger i in if i > (toInteger (maxBound `asTypeOf` res)) then Nothing else Just res -- Best regards, Bulat mailto:bulat.zigans...@gmail.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe