@@ -5,6 +5,7 @@
55module Data.Yaml.Internal
66 (
77 ParseException(..)
8+ , prettyPrintParseException
89 , parse
910 , decodeHelper
1011 , decodeHelper_
@@ -52,7 +53,11 @@ data ParseException = NonScalarKey
5253 | NonStringKeyAlias Y.AnchorName Value
5354 | CyclicIncludes
5455 deriving (Show, Typeable)
55−instance Exception ParseException
56+
57+instance Exception ParseException where
58+#if MIN_VERSION_base(4, 8, 0)
59+ displayException = prettyPrintParseException
60+#endif
5661
5762-- | Alternative to 'show' to display a 'ParseException' on the screen.
5863-- Instead of displaying the data constructors applied to their arguments,
@@ -66,15 +71,16 @@ instance Exception ParseException
6671--
6772prettyPrintParseException :: ParseException -> String
6873prettyPrintParseException NonScalarKey = "Non scalar key"
69−prettyPrintParseException InvalidYaml mye =
74+prettyPrintParseException (InvalidYaml mye) =
7075 case mye of
7176 Just ye -> "Invalid yaml: " ++ show ye
7277 _ -> "Invalid yaml"
7378prettyPrintParseException (AesonException e) =
7479 "Aeson exception: " ++ e
80+prettyPrintParseException CyclicIncludes = "Cyclic includes"
81+prettyPrintParseException (OtherParseException e) =
82+ "Parse exception: " ++ show e
7583prettyPrintParseException pe = show pe
76−-- TODO: This is just a stab at the implementation.
77−-- If the idea is likely to be merged, I can develop it further.
7884
7985newtype PErrorT m a = PErrorT { runPErrorT :: m (Either ParseException a) }
8086instance Monad m => Functor (PErrorT m) where