|
1 | 1 | {-# LANGUAGE ApplicativeDo #-} |
2 | 2 | {-# LANGUAGE ConstraintKinds #-} |
| 3 | +{-# LANGUAGE CPP #-} |
3 | 4 | {-# LANGUAGE DefaultSignatures #-} |
4 | 5 | {-# LANGUAGE DeriveFunctor #-} |
5 | 6 | {-# LANGUAGE DerivingStrategies #-} |
@@ -135,7 +136,12 @@ module Dhall.Marshal.Decode |
135 | 136 | ) where |
136 | 137 |
|
137 | 138 |
|
138 | | -import Control.Applicative (empty, liftA2) |
| 139 | +import Control.Applicative |
| 140 | + ( empty |
| 141 | +#if !MIN_VERSION_base(4,18,0) |
| 142 | + , liftA2 |
| 143 | +#endif |
| 144 | + ) |
139 | 145 | import Control.Exception (Exception) |
140 | 146 | import Control.Monad (guard) |
141 | 147 | import Control.Monad.Trans.State.Strict |
@@ -1604,14 +1610,15 @@ data ExtractError s a = |
1604 | 1610 | instance (Pretty s, Pretty a, Typeable s, Typeable a) => Show (ExtractError s a) where |
1605 | 1611 | show (TypeMismatch e) = show e |
1606 | 1612 | show (ExpectedTypeError e) = show e |
1607 | | - show (ExtractError es) = |
1608 | | - _ERROR <> ": Failed extraction \n\ |
1609 | | - \ \n\ |
1610 | | - \The expression type-checked successfully but the transformation to the target \n\ |
1611 | | - \type failed with the following error: \n\ |
1612 | | - \ \n\ |
1613 | | - \" <> Data.Text.unpack es <> "\n\ |
1614 | | - \ \n" |
| 1613 | + show (ExtractError es) = unlines |
| 1614 | + [ _ERROR <> ": Failed extraction " |
| 1615 | + , " " |
| 1616 | + , "The expression type-checked successfully but the transformation to the target " |
| 1617 | + , "type failed with the following error: " |
| 1618 | + , " " |
| 1619 | + , Data.Text.unpack es |
| 1620 | + , " " |
| 1621 | + ] |
1615 | 1622 |
|
1616 | 1623 | instance (Pretty s, Pretty a, Typeable s, Typeable a) => Exception (ExtractError s a) |
1617 | 1624 |
|
@@ -1669,24 +1676,22 @@ data InvalidDecoder s a = InvalidDecoder |
1669 | 1676 | instance (Pretty s, Typeable s, Pretty a, Typeable a) => Exception (InvalidDecoder s a) |
1670 | 1677 |
|
1671 | 1678 | instance (Pretty s, Pretty a, Typeable s, Typeable a) => Show (InvalidDecoder s a) where |
1672 | | - show InvalidDecoder { .. } = |
1673 | | - _ERROR <> ": Invalid Dhall.Decoder \n\ |
1674 | | - \ \n\ |
1675 | | - \Every Decoder must provide an extract function that does not fail with a type \n\ |
1676 | | - \error if an expression matches the expected type. You provided a Decoder that \n\ |
1677 | | - \disobeys this contract \n\ |
1678 | | - \ \n\ |
1679 | | - \The Decoder provided has the expected dhall type: \n\ |
1680 | | - \ \n\ |
1681 | | - \" <> show txt0 <> "\n\ |
1682 | | - \ \n\ |
1683 | | - \and it threw a type error during extraction from the well-typed expression: \n\ |
1684 | | - \ \n\ |
1685 | | - \" <> show txt1 <> "\n\ |
1686 | | - \ \n" |
1687 | | - where |
1688 | | - txt0 = Dhall.Util.insert invalidDecoderExpected |
1689 | | - txt1 = Dhall.Util.insert invalidDecoderExpression |
| 1679 | + show InvalidDecoder { .. } = unlines |
| 1680 | + [ _ERROR <> ": Invalid Dhall.Decoder " |
| 1681 | + , " " |
| 1682 | + , "Every Decoder must provide an extract function that does not fail with a type " |
| 1683 | + , "error if an expression matches the expected type. You provided a Decoder that " |
| 1684 | + , "disobeys this contract " |
| 1685 | + , " " |
| 1686 | + , "The Decoder provided has the expected dhall type: " |
| 1687 | + , " " |
| 1688 | + , show (Dhall.Util.insert invalidDecoderExpected) |
| 1689 | + , " " |
| 1690 | + , "and it threw a type error during extraction from the well-typed expression: " |
| 1691 | + , " " |
| 1692 | + , show (Dhall.Util.insert invalidDecoderExpression) |
| 1693 | + , " " |
| 1694 | + ] |
1690 | 1695 |
|
1691 | 1696 | {-| Useful synonym for the `Validation` type used when marshalling Dhall |
1692 | 1697 | expressions. |
|
0 commit comments