@@ -4252,21 +4252,23 @@ data TypeError s a = TypeError
4252
4252
}
4253
4253
4254
4254
instance (Eq a , Pretty s , Pretty a ) => Show (TypeError s a ) where
4255
- show = Pretty. renderString . Dhall.Pretty. layout . Pretty. pretty
4255
+ show = Pretty. renderString . Dhall.Pretty. layout . prettyTypeError
4256
4256
4257
4257
instance (Eq a , Pretty s , Pretty a , Typeable s , Typeable a ) => Exception (TypeError s a )
4258
4258
4259
4259
instance (Eq a , Pretty s , Pretty a ) => Pretty (TypeError s a ) where
4260
- pretty (TypeError _ expr msg)
4261
- = Pretty. unAnnotate
4262
- ( " \n "
4263
- <> shortTypeMessage msg <> " \n "
4264
- <> source
4265
- )
4266
- where
4267
- source = case expr of
4268
- Note s _ -> pretty s
4269
- _ -> mempty
4260
+ pretty = Pretty. unAnnotate . prettyTypeError
4261
+
4262
+ prettyTypeError :: (Eq a , Pretty s , Pretty a ) => TypeError s a -> Doc Ann
4263
+ prettyTypeError (TypeError _ expr msg) =
4264
+ ( " \n "
4265
+ <> shortTypeMessage msg <> " \n "
4266
+ <> source
4267
+ )
4268
+ where
4269
+ source = case expr of
4270
+ Note s _ -> pretty s
4271
+ _ -> mempty
4270
4272
4271
4273
{-| Wrap a type error in this exception type to censor source code and
4272
4274
`Text` literals from the error message
@@ -4425,36 +4427,39 @@ newtype DetailedTypeError s a = DetailedTypeError (TypeError s a)
4425
4427
deriving (Typeable )
4426
4428
4427
4429
instance (Eq a , Pretty s , Pretty a ) => Show (DetailedTypeError s a ) where
4428
- show = Pretty. renderString . Dhall.Pretty. layout . Pretty. pretty
4430
+ show = Pretty. renderString . Dhall.Pretty. layout . prettyDetailedTypeError
4429
4431
4430
4432
instance (Eq a , Pretty s , Pretty a , Typeable s , Typeable a ) => Exception (DetailedTypeError s a )
4431
4433
4432
4434
instance (Eq a , Pretty s , Pretty a ) => Pretty (DetailedTypeError s a ) where
4433
- pretty (DetailedTypeError (TypeError ctx expr msg))
4434
- = Pretty. unAnnotate
4435
- ( " \n "
4436
- <> ( if null (Dhall.Context. toList ctx)
4437
- then " "
4438
- else prettyContext ctx <> " \n\n "
4439
- )
4440
- <> longTypeMessage msg <> " \n "
4441
- <> " ────────────────────────────────────────────────────────────────────────────────\n "
4442
- <> " \n "
4443
- <> source
4444
- )
4445
- where
4446
- prettyKV (key, val) =
4447
- pretty key <> " : " <> Dhall.Util. snipDoc (pretty val)
4448
-
4449
- prettyContext =
4450
- Pretty. vsep
4451
- . map prettyKV
4452
- . reverse
4453
- . Dhall.Context. toList
4454
-
4455
- source = case expr of
4456
- Note s _ -> pretty s
4457
- _ -> mempty
4435
+ pretty = Pretty. unAnnotate . prettyDetailedTypeError
4436
+
4437
+ prettyDetailedTypeError :: (Eq a , Pretty s , Pretty a ) => DetailedTypeError s a -> Doc Ann
4438
+ prettyDetailedTypeError (DetailedTypeError (TypeError ctx expr msg)) =
4439
+ ( " \n "
4440
+ <> ( if null (Dhall.Context. toList ctx)
4441
+ then " "
4442
+ else prettyContext ctx <> " \n\n "
4443
+ )
4444
+ <> longTypeMessage msg <> " \n "
4445
+ <> " ────────────────────────────────────────────────────────────────────────────────\n "
4446
+ <> " \n "
4447
+ <> source
4448
+ )
4449
+ where
4450
+ prettyKV (key, val) =
4451
+ Dhall.Util. snipDoc
4452
+ (Dhall.Pretty.Internal. prettyLabel key <> " : " <> Dhall.Pretty. prettyExpr val)
4453
+
4454
+ prettyContext =
4455
+ Pretty. vsep
4456
+ . map prettyKV
4457
+ . reverse
4458
+ . Dhall.Context. toList
4459
+
4460
+ source = case expr of
4461
+ Note s _ -> pretty s
4462
+ _ -> mempty
4458
4463
4459
4464
{-| This function verifies that a custom context is well-formed so that
4460
4465
type-checking will not loop
0 commit comments