[Haskell-cafe] Safe 'chr' function?
Myles C. Maxfield
myles.maxfield at gmail.com
Thu Jan 3 09:52:29 CET 2013
Thanks you two for your answers. Consider this issue closed now :-)
On Thu, Jan 3, 2013 at 12:05 AM, Michael Snoyman <michael at snoyman.com>wrote:
> You could wrap chr with a call to spoon. It's not the most elegant
> solution, but it works.
> On Thu, Jan 3, 2013 at 9:50 AM, Myles C. Maxfield <
> myles.maxfield at gmail.com> wrote:
>> I'm working on a general text-processing library  and one of my
>> quickcheck tests is designed to make sure that my library doesn't throw
>> exceptions (it returns an Either type on failure). However, there are some
>> inputs that cause me to pass bogus values to the 'chr' function (such
>> as 1208914), which causes it to throw an exception. Is there a version of
>> that function that is safe? (I'm hoping for something like Int -> Maybe
>> Char). Alternatively, is there a way to know ahead of time whether or not
>> an Int will cause 'chr' to throw an exception?
>> Myles C. Maxfield
>>  http://hackage.haskell.org/package/punycode
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe