purescript/purescript-exceptions

Rename "error"?

tfausak opened this issue · 4 comments

While working on purescript-batteries, I ran into a collision between Control.Monad.Eff.Exception.error and Control.Monad.Eff.Console.error. I think people are more likely to mean Console.error than Exception.error when they just say error.

I'm not sure what else I would call it, though. Maybe toError? Or perhaps there could be a throw :: String -> Eff (err :: EXCEPTION | e) a function, which would sidestep error and throwException.

Obviously this isn't a problem with this package per se. I could (and may) address this in purescript-batteries. But I wanted to open an issue here for discussion.

I would be in favour of throw = throwException <<< error. So far, the only function on Pursuit with that name is in neon, so there are (effectively) no clashes. Also, we already have unsafeThrow with type forall a. String -> a, so I think calling this function throw would be consistent.

Although I think we should still have a function String -> Error. If we do change the name to avoid clashes, I'd rather makeError or maybe newError than toError, although the clash doesn't bother me too much, honestly.

👍 for throw. That would mean error wouldn't be as necessary, since you could throw a string directly.

I'm trying to address this in purescript-neon instead.