@@ -36,14 +36,12 @@ import Data.Semigroup ((<>))
3636import Data.Text (Text)
3737import qualified Data.Text as Text
3838import Data.Text.Manipulate
39+import Debug.Trace
3940import Gen.Formatting
4041import Gen.Text
4142import Gen.Types
4243import Prelude hiding (sum)
4344
44−-- Just use hashmaps to lookup refs etc, and hide all the mutation
45−-- behind a StateT interface.
46−
4745data TType
4846 = TType Id
4947 | TLit Lit
@@ -118,7 +116,7 @@ solve :: Id -> AST Solved
118116solve k = Solved <$> prefix k <*> schema k <*> typeOf k <*> derive k
119117
120118typeOf :: Id -> AST TType
121−typeOf k = memo typed k go
119+typeOf k = loc "typeof" k $ memo typed k go
122120 where
123121 go s = fmap may $ case s of
124122 Obj {} -> pure (TType k)
@@ -133,7 +131,7 @@ typeOf k = memo typed k go
133131 | otherwise = TMaybe
134132
135133derive :: Id -> AST [Derive]
136−derive k = memo derived k go
134+derive k = loc "derive" k $ memo derived k go
137135 where
138136 go = \case
139137 Obj _ rs -> foldM props base (Map.elems rs)
@@ -146,6 +144,7 @@ derive k = memo derived k go
146144 Text -> base <> [DOrd, DIsString]
147145 Bool -> base <> enum
148146 Time -> base
147+ Date -> base
149148 Nat -> base
150149 _ -> base <> [DNum, DIntegral, DReal] <> enum
151150
@@ -156,7 +155,7 @@ derive k = memo derived k go
156155 base = [DEq, DRead, DShow, DData, DTypeable, DGeneric]
157156
158157prefix :: Id -> AST Pre
159−prefix n = memo prefixed n typ
158+prefix n = loc "prefix" n $ memo prefixed n typ
160159 where
161160 typ = \case
162161 Obj _ rs -> field rs
@@ -230,3 +229,6 @@ acronymPrefixes (idToText -> n) = map CI.mk (xs ++ map suffix ys)
230229
231230 -- SomeTestTType -> Som
232231 r6 = Text.take limit <$> listToMaybe (splitWords a)
232+
233+loc :: String -> Id -> a -> a
234+loc n r = trace (n ++ ": " ++ Text.unpack (idToText r))