{-# LANGUAGE ConstraintKinds #-}
module Data.Version.Extra(
module Data.Version,
readVersion
) where
import Partial
import Data.Version
import Data.List.Extra
import Text.ParserCombinators.ReadP
readVersion :: Partial => String -> Version
readVersion :: Partial => String -> Version
readVersion String
s =
case [ Version
x | (Version
x,String
"") <- ReadP Version -> ReadS Version
forall a. ReadP a -> ReadS a
readP_to_S ReadP Version
parseVersion ReadS Version -> ReadS Version
forall a b. (a -> b) -> a -> b
$ String -> String
trimEnd String
s] of
[Version
x] -> Version
x
[] -> String -> Version
forall a. Partial => String -> a
error String
"Data.Version.Extra.readVersion: no parse"
[Version]
_ -> String -> Version
forall a. Partial => String -> a
error String
"Data.Version.Extra.readVersion: ambiguous parse"