haskellari / postgresql-libpq

Low-level Haskell bindings for libpq
BSD 3-Clause "New" or "Revised" License
20 stars 27 forks source link

Why is `unescapeBytea` in IO? #56

Open ysangkok opened 9 months ago

ysangkok commented 9 months ago

This function seems pure to me, aside from the allocation that it does. But Haskell allocates in many places, and we still call those functions pure. I don't understand why unescapeBytea must be in IO? What kind of side effects can it perform?

phadej commented 9 months ago

But Haskell allocates in many places, and we still call those functions pure.

Sure, bytestring is littered with unsafePerformIOs.

But, there aren't a single unsafePerformIO in postgresql-libpq, so the bar of introducing the first one is extremely high.