Skip to content

Consistent type for 'readMaybe' and 'readEither' #286

@chshersh

Description

@chshersh

The two functions are used to parse types with the Read instance from String. However, they have a slightly different type (one is more polymorphic than the other):

  • readMaybe :: Read a => String -> Maybe a
  • readEither :: (ToString a, Read b) => a -> Either Text b

I think this difference in behaviour can be surprising for some users. So I propose to chose one of the following options:

  1. Both work with monomorphic String
  2. Both work with polymorphic ToString

Both approaches have benefits and drawbacks: String is more beginner-friendly and less surprises for relude users, ToString is more flexible and convenient.

My initial thought is that both functions should work with String, and we can have a module like Relude.Extra.Parse/Read/String where we can put more polymorphic functions, including the ones proposed in #161.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions