Re: How to use Read for Data.Version
Tom Ellis <[email protected]> Sat, 14 Aug 2021 18:10:49 +0100
| Newsgroups | gmane.comp.lang.haskell.libraries |
|---|---|
| Message-ID | <20210814171049.GB26993@cloudinit-builder> |
On Sat, Aug 14, 2021 at 06:53:08PM +0200, Andreas Abel 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
> ```
The Read instance is derived
https://hackage.haskell.org/package/base-4.15.0.0/docs/src/Data-Version.html#Version
so it behaves like any other derived Read instance:
Prelude Data.Version> read "Version {versionBranch = [8,10,5], versionTags = []}" :: Version
Version {versionBranch = [8,10,5], versionTags = []}
Tom
_______________________________________________
Libraries mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries