1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE Rank2Types #-}
4 module Distribution
.Backpack
.DescribeUnitId
where
6 import Distribution
.Compat
.Prelude
9 import Distribution
.Compat
.Stack
10 import Distribution
.ModuleName
11 import Distribution
.Pretty
12 import Distribution
.Simple
.Utils
13 import Distribution
.Types
.ComponentName
14 import Distribution
.Types
.PackageId
15 import Distribution
.Verbosity
17 import Text
.PrettyPrint
19 -- Unit identifiers have a well defined, machine-readable format,
20 -- but this format isn't very user-friendly for users. This
21 -- module defines some functions for solving common rendering
22 -- problems one has for displaying these.
24 -- There are three basic problems we tackle:
26 -- - Users don't want to see pkg-0.5-inplace-libname,
27 -- they want to see "library 'libname' from 'pkg-0.5'"
29 -- - Users don't want to see the raw component identifier, which
30 -- usually contains a wordy hash that doesn't matter.
32 -- - Users don't want to see a hash of the instantiation: they
33 -- want to see the actual instantiation, and they want it in
34 -- interpretable form.
37 -- | Print a Setup message stating (1) what operation we are doing,
38 -- for (2) which component (with enough details to uniquely identify
39 -- the build in question.)
44 -- ^ Operation being done (capitalized), on:
49 -> Maybe [(ModuleName
, a
)]
50 -- ^ Instantiation, if available.
51 -- Polymorphic to take
52 -- 'OpenModule' or 'Module'
54 setupMessage
' verbosity msg pkgid cname mb_insts
= withFrozenCallStack
$ do
60 (msg_doc
<+> text
"instantiated with")
63 [ pretty k
<+> text
"=" <+> pretty v
71 msg_doc
= text msg
<+> text
(showComponentName cname
)
72 for_doc
= text
"for" <+> pretty pkgid
<<>> text
"..."