catchError vs catchException argument order

The argument order of catchError and catchException is reversed.

catchError     :: forall a.           m a       -> (e -> m a) ->   m a
catchException :: forall a. (Error -> Effect a) ->  Effect a  -> Effect a

Is there a a reason for the current ordering, and how do we feel about changing one of these for consistency?

I think the ordering of catchError is best, since it allows you to use infix notation to closely match the structure of JS code.

foo().catch( e => console.log('Error with foo: ' + e.message) )
foo `catchError` \e -> log $ "Error with foo: " <> message e
1 Like

I personally prefer the order in catchException, because anytime I’ve wanted to partially apply this function it’s been with an error handler, and you can get the infixy dsl behavior with foo # catchException \e -> .... That being said, changing catchException would likely result in far far less breakage.