@@ -4,21 +4,12 @@ module Main (main) where
44
55import Codec.CBOR.Cuddle.CBOR.Gen (generateCBORTerm )
66import Codec.CBOR.Cuddle.CBOR.Validator
7- import Codec.CBOR.Cuddle.CDDL (
8- CDDL (.. ),
9- Name (.. ),
10- TopLevel (.. ),
11- XRule ,
12- XTerm ,
13- XXType2 ,
14- fromRules ,
15- sortCDDL ,
16- )
7+ import Codec.CBOR.Cuddle.CDDL (Name (.. ), fromRules , sortCDDL )
178import Codec.CBOR.Cuddle.CDDL.Postlude (appendPostlude )
189import Codec.CBOR.Cuddle.CDDL.Resolve (
1910 fullResolveCDDL ,
2011 )
21- import Codec.CBOR.Cuddle.IndexMappable (IndexMappable (.. ))
12+ import Codec.CBOR.Cuddle.IndexMappable (IndexMappable (.. ), mapCDDLDropExt )
2213import Codec.CBOR.Cuddle.Parser (pCDDL )
2314import Codec.CBOR.Cuddle.Pretty (PrettyStage )
2415import Codec.CBOR.FlatTerm (toFlatTerm )
@@ -186,15 +177,6 @@ main = do
186177
187178run :: Opts -> IO ()
188179run (Opts cmd cddlFile) = do
189- let
190- mapRule ::
191- ( IndexMappable XXType2 i j
192- , IndexMappable XTerm i j
193- , IndexMappable XRule i j
194- ) =>
195- TopLevel i -> [TopLevel j ]
196- mapRule (TopLevelRule r) = [TopLevelRule $ mapIndex r]
197- mapRule (XXTopLevel _) = []
198180 parseFromFile pCDDL cddlFile >>= \ case
199181 Left err -> do
200182 putStrLnErr $ errorBundlePretty err
@@ -210,20 +192,20 @@ run (Opts cmd cddlFile) = do
210192 putDocW 80 . pretty $ mapIndex @ _ @ _ @ PrettyStage defs
211193 Validate vOpts ->
212194 let
213- CDDL r tls _
195+ cddl
214196 | vNoPrelude vOpts = res
215197 | otherwise = appendPostlude res
216198 in
217- case fullResolveCDDL $ CDDL (mapIndex r) ( foldMap mapRule tls) mempty of
199+ case fullResolveCDDL $ mapCDDLDropExt cddl of
218200 Left err -> putStrLnErr (show err) >> exitFailure
219201 Right _ -> exitSuccess
220202 (GenerateCBOR gOpts) ->
221203 let
222- CDDL r tls _
204+ cddl
223205 | gNoPrelude gOpts = res
224206 | otherwise = appendPostlude res
225207 in
226- case fullResolveCDDL $ CDDL (mapIndex r) ( foldMap mapRule tls) mempty of
208+ case fullResolveCDDL $ mapCDDLDropExt cddl of
227209 Left err -> putStrLnErr (show err) >> exitFailure
228210 Right mt -> do
229211 stdGen <- getStdGen
@@ -237,11 +219,11 @@ run (Opts cmd cddlFile) = do
237219 AsPrettyCBOR -> putStrLn . prettyHexEnc $ encodeTerm term
238220 ValidateCBOR vcOpts ->
239221 let
240- CDDL r tls _
222+ cddl
241223 | vcNoPrelude vcOpts = res
242224 | otherwise = res
243225 in
244- case fullResolveCDDL $ CDDL (mapIndex r) ( foldMap mapRule tls) mempty of
226+ case fullResolveCDDL $ mapCDDLDropExt cddl of
245227 Left err -> putStrLnErr (show err) >> exitFailure
246228 Right mt -> do
247229 cbor <- BSC. readFile (vcInput vcOpts)
0 commit comments