Lucas Paul | 20 Feb 01:12 2014
Picon

Text and ByteString safety (was Naming scheme for partial functions)

I'm still a little new to Haskell. Could someone explain how Text and
ByteString "push the boundaries of 'unsafe'"?

On Sat, Feb 15, 2014 at 8:40 AM, Antoine Latter <aslatter <at> gmail.com> wrote:
> Yeah, that's a good point.Text and Bytestring (and other similar packages)
> have been pushing the boundaries of 'unsafe' and are in wide use.
Michael Snoyman | 20 Feb 05:50 2014

Re: Text and ByteString safety (was Naming scheme for partial functions)

I'm not sure about Text, but both the bytestring and vector packages provide functions like unsafeIndex. The closest equivalent to that in base would be (!!), which indexes on a list. If you give it an invalid index, it will throw an exception from pure code (a.k.a., it's a partial function). That kind of exception can cause problems if you don't expect it, but in the nearest IO code, you can still catch that exception and let your program continue operating.

unsafeIndex, on the other hand, performs a memory access which may not just throw an exception, but could actually cause your program to segfault. There would be no way to recover from that, unlike partial functions.

I think that's what Antoine is implying, please correct me if I'm mistaken :).


On Thu, Feb 20, 2014 at 2:12 AM, Lucas Paul <reilithion <at> gmail.com> wrote:
I'm still a little new to Haskell. Could someone explain how Text and
ByteString "push the boundaries of 'unsafe'"?

On Sat, Feb 15, 2014 at 8:40 AM, Antoine Latter <aslatter <at> gmail.com> wrote:
> Yeah, that's a good point.Text and Bytestring (and other similar packages)
> have been pushing the boundaries of 'unsafe' and are in wide use.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane