Skip to content

Commit cc2a57f

Browse files
theobatmpilgrem
authored andcommitted
feat: move ghcpkgid to cabal's unitid
1 parent b403d1b commit cc2a57f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Stack/Types/GhcPkgId.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import Data.Char ( isAlphaNum )
1919
import Data.Hashable ( Hashable(..) )
2020
import Database.Persist.Sql ( PersistField (..), PersistFieldSql (..) )
2121
import Distribution.Compat.Binary ( decode, encode )
22-
import Distribution.Utils.ShortText ( ShortText, toShortText, fromShortText )
2322
import Stack.Prelude
2423
import Text.Read ( Read (..) )
24+
import Distribution.Types.UnitId (UnitId, mkUnitId, unUnitId)
2525

2626
-- | A parse fail.
2727
newtype GhcPkgIdParseFail
@@ -37,7 +37,7 @@ instance Exception GhcPkgIdParseFail where
3737

3838
-- | A ghc-pkg package identifier.
3939
newtype GhcPkgId
40-
= GhcPkgId ShortText
40+
= GhcPkgId UnitId
4141
deriving (Data, Eq, Generic, Ord, Typeable)
4242

4343
instance PersistField GhcPkgId where
@@ -56,7 +56,7 @@ instance Show GhcPkgId where
5656
show = show . ghcPkgIdString
5757

5858
instance Read GhcPkgId where
59-
readsPrec i = map (first (GhcPkgId . toShortText)) . readsPrec i
59+
readsPrec i = map (first (GhcPkgId . mkUnitId)) . readsPrec i
6060

6161
instance FromJSON GhcPkgId where
6262
parseJSON = withText "GhcPkgId" $ \t ->
@@ -80,7 +80,7 @@ parseGhcPkgId x = go x
8080
ghcPkgIdParser :: Parser GhcPkgId
8181
ghcPkgIdParser =
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.
9292
ghcPkgIdString :: GhcPkgId -> String
93-
ghcPkgIdString (GhcPkgId x) = fromShortText x
93+
ghcPkgIdString (GhcPkgId x) = unUnitId x
9494

9595
-- | Get a text value of GHC package id.
9696
ghcPkgIdToText :: GhcPkgId -> Text

0 commit comments

Comments
 (0)