@@ -19,9 +19,9 @@ import Data.Char ( isAlphaNum )
19
19
import Data.Hashable ( Hashable (.. ) )
20
20
import Database.Persist.Sql ( PersistField (.. ), PersistFieldSql (.. ) )
21
21
import Distribution.Compat.Binary ( decode , encode )
22
- import Distribution.Utils.ShortText ( ShortText , toShortText , fromShortText )
23
22
import Stack.Prelude
24
23
import Text.Read ( Read (.. ) )
24
+ import Distribution.Types.UnitId (UnitId , mkUnitId , unUnitId )
25
25
26
26
-- | A parse fail.
27
27
newtype GhcPkgIdParseFail
@@ -37,7 +37,7 @@ instance Exception GhcPkgIdParseFail where
37
37
38
38
-- | A ghc-pkg package identifier.
39
39
newtype GhcPkgId
40
- = GhcPkgId ShortText
40
+ = GhcPkgId UnitId
41
41
deriving (Data , Eq , Generic , Ord , Typeable )
42
42
43
43
instance PersistField GhcPkgId where
@@ -56,7 +56,7 @@ instance Show GhcPkgId where
56
56
show = show . ghcPkgIdString
57
57
58
58
instance Read GhcPkgId where
59
- readsPrec i = map (first (GhcPkgId . toShortText )) . readsPrec i
59
+ readsPrec i = map (first (GhcPkgId . mkUnitId )) . readsPrec i
60
60
61
61
instance FromJSON GhcPkgId where
62
62
parseJSON = withText " GhcPkgId" $ \ t ->
@@ -80,7 +80,7 @@ parseGhcPkgId x = go x
80
80
ghcPkgIdParser :: Parser GhcPkgId
81
81
ghcPkgIdParser =
82
82
let elements = " _.-" :: String
83
- in GhcPkgId . toShortText <$>
83
+ in GhcPkgId . mkUnitId <$>
84
84
many1 (choice [alphaNum, satisfy (`elem` elements)])
85
85
86
86
-- | Parse an alphanumerical character, as recognised by `isAlphaNum`.
@@ -90,7 +90,7 @@ alphaNum = satisfy isAlphaNum <?> "alphanumeric"
90
90
91
91
-- | Get a string representation of GHC package id.
92
92
ghcPkgIdString :: GhcPkgId -> String
93
- ghcPkgIdString (GhcPkgId x) = fromShortText x
93
+ ghcPkgIdString (GhcPkgId x) = unUnitId x
94
94
95
95
-- | Get a text value of GHC package id.
96
96
ghcPkgIdToText :: GhcPkgId -> Text
0 commit comments