Skip to content

Commit

Permalink
use Text instead of ByteString for Version
Browse files Browse the repository at this point in the history
  • Loading branch information
kadoban committed Nov 19, 2015
1 parent f79359b commit 5b97845
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Stack/Types/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ import Control.Applicative
import Control.DeepSeq
import Control.Monad.Catch
import Data.Aeson.Extended
import Data.Attoparsec.ByteString.Char8
import Data.Attoparsec.Text
import Data.Binary.VersionTagged (Binary, HasStructuralInfo)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as S8
import Data.Data
import Data.Hashable
import Data.List
Expand All @@ -57,7 +55,7 @@ import Text.PrettyPrint (render)

-- | A parse fail.
data VersionParseFail =
VersionParseFail ByteString
VersionParseFail Text
deriving (Typeable)
instance Exception VersionParseFail
instance Show VersionParseFail where
Expand Down Expand Up @@ -113,7 +111,7 @@ versionParser =
point = satisfy (== '.')

-- | Convenient way to parse a package version from a bytestring.
parseVersion :: MonadThrow m => ByteString -> m Version
parseVersion :: MonadThrow m => Text -> m Version
parseVersion x = go x
where go =
either (const (throwM (VersionParseFail x))) return .
Expand All @@ -122,7 +120,7 @@ parseVersion x = go x
-- | Migration function.
parseVersionFromString :: MonadThrow m => String -> m Version
parseVersionFromString =
parseVersion . S8.pack
parseVersion . T.pack

-- | Get a string representation of a package version.
versionString :: Version -> String
Expand Down

0 comments on commit 5b97845

Please sign in to comment.