How to use Read for Data.Version

Andreas Abel andreas.abel at ifi.lmu.de
Sat Aug 14 17:09:16 UTC 2021


Thanks for the quick answer.  Indeed, I confused Read and ReadP!  --Andreas

On 2021-08-14 19:06, chessai wrote:
> Looking at the source code [1], Read is derived, and not using 
> parseVersion (which has the behaviour I think you expect).
> 
> You may want to use parseVersion directly.
> 
> [1]: 
> https://hackage.haskell.org/package/base-4.15.0.0/docs/src/Data-Version.html 
> <https://hackage.haskell.org/package/base-4.15.0.0/docs/src/Data-Version.html>
> 
> On Sat, Aug 14, 2021, 11:55 Andreas Abel <andreas.abel at ifi.lmu.de 
> <mailto:andreas.abel at ifi.lmu.de>> wrote:
> 
>     How is the parser for Data.Version supposed to work?
> 
>     ```haskell
>     import Data.Version
> 
>     readVersion :: String -> Version
>     readVersion = read
> 
>     main :: IO ()
>     main = print $ readVersion "8.10.5"
> 
>     -- *** Exception: Prelude.read: no parse
>     ```
> 
>     P.S.: Maintainer libraries at haskell.org <mailto:libraries at haskell.org>
>     _______________________________________________
>     Libraries mailing list
>     Libraries at haskell.org <mailto:Libraries at haskell.org>
>     http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>     <http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries>
> 


More information about the Libraries mailing list