serokell / universum

:milky_way: Prelude written in @Serokell
MIT License
176 stars 28 forks source link

Change the type of `readMaybe` #165

Closed gromakovsky closed 2 years ago

gromakovsky commented 6 years ago

We have the following function: readMaybe :: Read a => String -> Maybe a. I find it weird, because:

  1. One of key points in the design of Universum is to avoid String as much as possible. However, this function's argument is String.
  2. We also have readEither :: (ToString a, Read b) => a -> Either Text b, which takes anything convertible to String as an argument. This function is very similar to readMaybe and I think their arguments should have same types.
chshersh commented 6 years ago

@gromakovsky I appreciate this change. But this is the breaking change since such code will no longer compile:

readMaybe (show x) == Just x

Maybe we can sneak in this change into next major release :smirk: :smiling_imp: