
factFromJSON :: (?q::SMTQuery) => DFSession -> J.Value -> IO Fact
factFromJSON df f@(J.Object vs) = case H.toList vs of
                                       [(rname, v)] -> rowFromJSON df (unpack rname) v
                                       _            -> err $ "Invalid JSON fact: " ++ show f
factFromJSON _  f = err $ "Invalid JSON fact: " ++ show f

rowFromJSON :: DFSession -> String -> J.Value -> IO Fact
rowFromJSON DFSession{..} rname val = do
    let Relation{..} = fromJust $ find ((== rname) . name) dfRels
    let ?q = dfQ