commercialhaskell / path

Typed filepath
Other
122 stars 45 forks source link

Add a `Read` instance (dup) #188

Closed bitc closed 2 months ago

bitc commented 2 years ago

This is a duplicate of #139 but I have different needs.

I use QuickCheck, and when it finds a failure, it prints out the failing input as a string using "show".

Sometimes I would like to manually run this same input again. The easiest way is to copy&paste this output directly into my source code (using something like Text-RawString-QQ) and then convert it into the input using "read".

Without "read", I must manually fixup the string so it will be valid Haskell code. This often involves adding qualifications to stuff like "fromList", and in the case of this library, requires converting all path strings to quasiquote format. This is obviously quite annoying and a frustrating waste of time.

A Read instance would streamline this workflow greatly (in addition to having other possible benefits). I am not aware of any downsides to adding a Read instance.

Thank you

NorfairKing commented 2 years ago

I think it's possible to make this work safely, but I have no idea how to implement it. PR welcome.