@@ -45,6 +45,8 @@ flatten s = do
45 -- The horror.
45 -- The horror.
46 ss <- use schemas
46 ss <- use schemas
48+ -- _ <- mapM (\k -> trace (show k) $ return 1) (Map.keys ss)
48 reserveBranches
50 reserveBranches
49 reserveFields
51 reserveFields
@@ -73,11 +75,10 @@ localSchema g l = schema g (Just l)
73schema :: Global -> Maybe Local -> Fix Schema -> AST Global
75schema :: Global -> Maybe Local -> Fix Schema -> AST Global
74schema g ml (Fix f) = go (maybe g (reference g) ml) f >>= uncurry insert
76schema g ml (Fix f) = go (maybe g (reference g) ml) f >>= uncurry insert
76− go :: Global -> Schema (Fix Schema) -> AST (Global, Schema Global)
77 go p = \case
78 go p = \case
78− SAny i a -> pure (p, SAny i a)
79+ SAny i a -> pure (reference p "Any", SAny i a)
79− SRef i r -> pure (p, SRef i r)
80+ SRef i r -> pure (reference p "Ref", SRef i r)
80− SLit i l -> pure (p, SLit i l)
81+ SLit i l -> pure (reference p "Lit", SLit i l)
81 SEnm i e -> (,SEnm i e) <$> name i p ["Type", "Option"]
82 SEnm i e -> (,SEnm i e) <$> name i p ["Type", "Option"]
82 SArr i a -> do
83 SArr i a -> do
83 u <- name i p ["List", "Array"]
84 u <- name i p ["List", "Array"]
@@ -92,16 +93,17 @@ schema g ml (Fix f) = go (maybe g (reference g) ml) f >>= uncurry insert
92 object p (Obj aps ps) =
93 object p (Obj aps ps) =
93 Obj Nothing <$> Map.traverseWithKey (localSchema p) ps
94 Obj Nothing <$> Map.traverseWithKey (localSchema p) ps
96− | Just x <- i ^. iId = pure x
96+ -- | Just x <- i ^. iId = pure x
97− | otherwise = do
97+ -- | otherwise = do
98− e <- uses schemas (Map.lookup p)
100+ e <- uses schemas (Map.lookup p)
99− case (e, xs) of
101+ case (e, xs) of
100− (Nothing, _) -> pure p
102+ (Nothing, _) -> pure p
101− (Just _, z:zs) -> name i (reference g z) zs
103+ (Just _, z:zs) -> name i (reference g z) zs
102− (Just x, []) -> throwError $
104+ (Just x, []) -> throwError $
103− format ("Unable to generate name for: " % gid % ", " % shown % ", " % gid % "\n" % shown)
105+ format ("Unable to generate name for: " % gid % ", " % shown % ", " % gid % "\n" % shown)
104− g ml p x
106+ g ml p x
106globalParam :: Local -> Param (Fix Schema) -> AST (Param Global)
108globalParam :: Local -> Param (Fix Schema) -> AST (Param Global)
107globalParam l p = ($ p) $ case l of
109globalParam l p = ($ p) $ case l of