Skip to content

Commit fe84ead

Browse files
Rename BaseDecodeError => DecodeErrorKind (#29)
* Rename BaseDecodeError => DecodeErrorKind * Add new BaseDecodeError alias * Prune DecodeM re-exports in KDL.Decoder.Arrow
1 parent 591ff8c commit fe84ead

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/KDL/Decoder/Arrow.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ module KDL.Decoder.Arrow (
1212

1313
-- * Decoder
1414
Decoder,
15-
module KDL.Decoder.Internal.DecodeM,
15+
liftDecodeM,
1616
fail,
1717
withDecoder,
1818
debug,
1919

20+
-- ** DecodeM
21+
DecodeM,
22+
runDecodeM,
23+
decodeThrow,
24+
failM,
25+
26+
-- ** Decode errors
27+
module KDL.Decoder.Internal.Error,
28+
2029
-- * Document
2130
DocumentDecoder (..),
2231
document,
@@ -112,6 +121,7 @@ import Data.Word (Word16, Word32, Word64, Word8)
112121
import GHC.Int (Int16, Int32, Int8)
113122
import KDL.Decoder.Internal.DecodeM
114123
import KDL.Decoder.Internal.Decoder
124+
import KDL.Decoder.Internal.Error
115125
import KDL.Decoder.Schema (
116126
Schema (..),
117127
SchemaItem (..),

src/KDL/Decoder/Internal/DecodeM.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ runDecodeM (DecodeM f) = f Left Left Right
7070
--
7171
-- This error is non-fatal and can be handled by '<|>'. See 'makeFatal'
7272
-- for more information.
73-
decodeThrow :: BaseDecodeError -> DecodeM a
73+
decodeThrow :: DecodeErrorKind -> DecodeM a
7474
decodeThrow e = DecodeM $ \_ onFail _ -> onFail $ DecodeError Nothing [([], e)]
7575

7676
-- | Throw a 'DecodeError_Custom' error.

src/KDL/Decoder/Internal/Error.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
module KDL.Decoder.Internal.Error (
99
DecodeError (..),
10-
BaseDecodeError (..),
10+
BaseDecodeError,
11+
DecodeErrorKind (..),
1112
Context,
1213
ContextItem (..),
1314
renderDecodeError,
@@ -28,14 +29,15 @@ import KDL.Types (
2829

2930
data DecodeError = DecodeError
3031
{ filepath :: Maybe FilePath
31-
, errors :: [(Context, BaseDecodeError)]
32+
, errors :: [BaseDecodeError]
3233
}
3334
deriving (Show, Eq)
3435
instance Semigroup DecodeError where
3536
DecodeError fp1 e1 <> DecodeError fp2 e2 = DecodeError (fp1 <|> fp2) (e1 <> e2)
3637
instance Monoid DecodeError where
3738
mempty = DecodeError Nothing []
3839

40+
type BaseDecodeError = (Context, DecodeErrorKind)
3941
type Context = [ContextItem]
4042

4143
data ContextItem
@@ -51,7 +53,7 @@ data ContextItem
5153
}
5254
deriving (Show, Eq, Ord)
5355

54-
data BaseDecodeError
56+
data DecodeErrorKind
5557
= DecodeError_Custom Text
5658
| DecodeError_ParseError Text
5759
| DecodeError_ExpectedNode {name :: Text, index :: Int}

0 commit comments

Comments
 (0)