velveteer / hermes

A Haskell library for fast, memory-efficient decoding of JSON documents using the simdjson C++ library

Home Page:https://hackage.haskell.org/package/hermes-json

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MonadIO considered harmful

velveteer opened this issue · comments

Decoder provides a MonadIO instance, which means a decoder can launch nukes. decodeEither centralizes the unsafePerformIO because it is convenient to use IO internally for exceptions and the unliftio machinery.

So if we lose MonadIO then we lose MonadUnliftIO, and we'll have to refactor how we handle error reporting. I think using a continuation-style like how attoparsec does it could be the better approach. All FFI operations will then need to use unsafePerformIO.

Alternatively, we can maybe get away with defining our own versions of lifting/unlifting IO and never export them.