safety of Data.Ascii.unsafeFromString

just how unsafe are the unsafeXXX functions in Data.Ascii? IS it just that you might get a runtime exception or could they do some more serious damage somehow? max

IIRC there is no checking at all.
Am 09.06.2011 13:05 schrieb "Max Cantor"
just how unsafe are the unsafeXXX functions in Data.Ascii? IS it just that you might get a runtime exception or could they do some more serious damage somehow?
max
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

You don't even get a runtime exception: your results are silently
broken. It's no worse than Data.ByteString.Char8.pack.
But the ascii package isn't really being used going forward, people
didn't like the extra noise it added to their code.
Michael
On Thu, Jun 9, 2011 at 2:04 PM, Max Cantor
just how unsafe are the unsafeXXX functions in Data.Ascii? IS it just that you might get a runtime exception or could they do some more serious damage somehow?
max
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

so, if i want to take the FileContentType from FileInfo, which is from fileField in forms, which is a Data.Text and convert that to a contentType to use in sendFile (which takes a ContentType which is a Data.ByteString), what is the preferred way to do that? max On Jun 9, 2011, at 7:07 PM, Michael Snoyman wrote:
You don't even get a runtime exception: your results are silently broken. It's no worse than Data.ByteString.Char8.pack.
But the ascii package isn't really being used going forward, people didn't like the extra noise it added to their code.
Michael
On Thu, Jun 9, 2011 at 2:04 PM, Max Cantor
wrote: just how unsafe are the unsafeXXX functions in Data.Ascii? IS it just that you might get a runtime exception or could they do some more serious damage somehow?
max
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

I would say to use the Data.Text.Encoding functions to convert to a
ByteString. If you want to be very careful, you should validate the
Text value to ensure there are no non-ASCII values first, but in
practice this probably should be an issue.
On Thu, Jun 9, 2011 at 2:10 PM, Max Cantor
so, if i want to take the FileContentType from FileInfo, which is from fileField in forms, which is a Data.Text and convert that to a contentType to use in sendFile (which takes a ContentType which is a Data.ByteString), what is the preferred way to do that?
max
On Jun 9, 2011, at 7:07 PM, Michael Snoyman wrote:
You don't even get a runtime exception: your results are silently broken. It's no worse than Data.ByteString.Char8.pack.
But the ascii package isn't really being used going forward, people didn't like the extra noise it added to their code.
Michael
On Thu, Jun 9, 2011 at 2:04 PM, Max Cantor
wrote: just how unsafe are the unsafeXXX functions in Data.Ascii? IS it just that you might get a runtime exception or could they do some more serious damage somehow?
max
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
participants (3)
-
Aristid Breitkreuz
-
Max Cantor
-
Michael Snoyman