@@ -19,9 +19,9 @@ import Data.Char ( isAlphaNum )
1919import Data.Hashable ( Hashable (.. ) )
2020import Database.Persist.Sql ( PersistField (.. ), PersistFieldSql (.. ) )
2121import Distribution.Compat.Binary ( decode , encode )
22- import Distribution.Utils.ShortText ( ShortText , toShortText , fromShortText )
2322import Stack.Prelude
2423import Text.Read ( Read (.. ) )
24+ import Distribution.Types.UnitId (UnitId , mkUnitId , unUnitId )
2525
2626-- | A parse fail.
2727newtype GhcPkgIdParseFail
@@ -37,7 +37,7 @@ instance Exception GhcPkgIdParseFail where
3737
3838-- | A ghc-pkg package identifier.
3939newtype GhcPkgId
40- = GhcPkgId ShortText
40+ = GhcPkgId UnitId
4141 deriving (Data , Eq , Generic , Ord , Typeable )
4242
4343instance PersistField GhcPkgId where
@@ -56,7 +56,7 @@ instance Show GhcPkgId where
5656 show = show . ghcPkgIdString
5757
5858instance Read GhcPkgId where
59- readsPrec i = map (first (GhcPkgId . toShortText )) . readsPrec i
59+ readsPrec i = map (first (GhcPkgId . mkUnitId )) . readsPrec i
6060
6161instance FromJSON GhcPkgId where
6262 parseJSON = withText " GhcPkgId" $ \ t ->
@@ -80,7 +80,7 @@ parseGhcPkgId x = go x
8080ghcPkgIdParser :: Parser GhcPkgId
8181ghcPkgIdParser =
8282 let elements = " _.-" :: String
83- in GhcPkgId . toShortText <$>
83+ in GhcPkgId . mkUnitId <$>
8484 many1 (choice [alphaNum, satisfy (`elem` elements)])
8585
8686-- | Parse an alphanumerical character, as recognised by `isAlphaNum`.
@@ -90,7 +90,7 @@ alphaNum = satisfy isAlphaNum <?> "alphanumeric"
9090
9191-- | Get a string representation of GHC package id.
9292ghcPkgIdString :: GhcPkgId -> String
93- ghcPkgIdString (GhcPkgId x) = fromShortText x
93+ ghcPkgIdString (GhcPkgId x) = unUnitId x
9494
9595-- | Get a text value of GHC package id.
9696ghcPkgIdToText :: GhcPkgId -> Text
0 commit comments