@@ -4,13 +4,14 @@ module Main (main) where
44
55import Codec.CBOR.Cuddle.CBOR.Gen (generateCBORTerm )
66import Codec.CBOR.Cuddle.CBOR.Validator
7- import Codec.CBOR.Cuddle.CDDL (Name (.. ), sortCDDL )
8- import Codec.CBOR.Cuddle.CDDL.Prelude ( prependPrelude )
7+ import Codec.CBOR.Cuddle.CDDL (Name (.. ), fromRules , sortCDDL )
8+ import Codec.CBOR.Cuddle.CDDL.Postlude ( appendPostlude )
99import Codec.CBOR.Cuddle.CDDL.Resolve (
1010 fullResolveCDDL ,
1111 )
12+ import Codec.CBOR.Cuddle.IndexMappable (IndexMappable (.. ))
1213import Codec.CBOR.Cuddle.Parser (pCDDL )
13- import Codec.CBOR.Cuddle.Pretty ()
14+ import Codec.CBOR.Cuddle.Pretty (PrettyStage )
1415import Codec.CBOR.FlatTerm (toFlatTerm )
1516import Codec.CBOR.Pretty (prettyHexEnc )
1617import Codec.CBOR.Term (encodeTerm )
@@ -185,26 +186,26 @@ run (Opts cmd cddlFile) = do
185186 Format fOpts ->
186187 let
187188 defs
188- | sort fOpts = sortCDDL res
189+ | sort fOpts = fromRules $ sortCDDL res
189190 | otherwise = res
190191 in
191- putDocW 80 $ pretty defs
192+ putDocW 80 . pretty $ mapIndex @ _ @ _ @ PrettyStage defs
192193 Validate vOpts ->
193194 let
194195 res'
195196 | vNoPrelude vOpts = res
196- | otherwise = prependPrelude res
197+ | otherwise = appendPostlude res
197198 in
198- case fullResolveCDDL res' of
199+ case fullResolveCDDL $ mapIndex res' of
199200 Left err -> putStrLnErr (show err) >> exitFailure
200201 Right _ -> exitSuccess
201202 (GenerateCBOR gOpts) ->
202203 let
203204 res'
204205 | gNoPrelude gOpts = res
205- | otherwise = prependPrelude res
206+ | otherwise = appendPostlude res
206207 in
207- case fullResolveCDDL res' of
208+ case fullResolveCDDL $ mapIndex res' of
208209 Left err -> putStrLnErr (show err) >> exitFailure
209210 Right mt -> do
210211 stdGen <- getStdGen
@@ -220,9 +221,9 @@ run (Opts cmd cddlFile) = do
220221 let
221222 res'
222223 | vcNoPrelude vcOpts = res
223- | otherwise = prependPrelude res
224+ | otherwise = res
224225 in
225- case fullResolveCDDL res' of
226+ case fullResolveCDDL $ mapIndex res' of
226227 Left err -> putStrLnErr (show err) >> exitFailure
227228 Right mt -> do
228229 cbor <- BSC. readFile (vcInput vcOpts)
0 commit comments