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