frasertweedale / hs-jose

Haskell JOSE and JWT library
http://hackage.haskell.org/package/jose
Apache License 2.0
122 stars 46 forks source link

[Question] replacing removed `fromString` when upgrading to 0.6 #58

Closed PierreR closed 6 years ago

PierreR commented 6 years ago

While migrating from 0.5 to 0.6 (for the posgrest project) I have to face 9ed8fe19f9b84efe458c23876ed70920c0207697 and the change from Text to String in StringOrUri.

What is the idiomatic way to replace the removed fromString function ? As the comment on the PR suggests, the following does not seem satisfying:

Text -> StringOrUri

let audience' = fromJust $ preview stringOrUri audience

Thanks for your help

frasertweedale commented 6 years ago

The IsString instance is still there, but as the comment says, it is partial. If you are working with a known value you can use fromString or fromJust . preview stringOrUri without remorse. If it is user-specified use the stringOrUri prism and handle the Nothing case as an error, in whatever way is appropriate for the application.

PierreR commented 6 years ago

@frasertweedale Thanks for your help. Don't want to bother further with this but my concern was also about the level of "conversion" between Text and String implicit done by stringOrUri. Probably nothing to be worried about but well ... going from Text and back to String (I am talking about StringOrUri) is unusual enough that I was wondering about ;-)