Commit 1103b2c9 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Annotate fromDBid with HasCallStack

parent e9c12cb0
......@@ -104,7 +104,7 @@ resolveParent (Just pId) = do
resolveParent Nothing = pure Nothing
nodeToTreeNode :: NN.Node json -> Maybe TreeNode
nodeToTreeNode :: HasCallStack => NN.Node json -> Maybe TreeNode
nodeToTreeNode N.Node {..} = if (fromDBid _node_typename /= NN.NodeFolderShared) && (fromDBid _node_typename /= NN.NodeTeam)
then
Just TreeNode { id = NN.unNodeId _node_id
......@@ -118,7 +118,7 @@ nodeToTreeNode N.Node {..} = if (fromDBid _node_typename /= NN.NodeFolderShared)
resolveBreadcrumb :: (CmdCommon env) => BreadcrumbArgs -> GqlM e env (BreadcrumbInfo)
resolveBreadcrumb BreadcrumbArgs { node_id } = dbRecursiveParents node_id
convertDbTreeToTreeNode :: T.DbTreeNode -> TreeNode
convertDbTreeToTreeNode :: HasCallStack => T.DbTreeNode -> TreeNode
convertDbTreeToTreeNode T.DbTreeNode { _dt_name, _dt_nodeId, _dt_typeId, _dt_parentId } = TreeNode
{ name = _dt_name
, id = NN.unNodeId _dt_nodeId
......
......@@ -186,6 +186,8 @@ instance HasDBid PosTagAlgo where
lookupDBid _ = Nothing
-- | Tries to convert the given integer into the relevant DB identifier, failing
-- with an error if the conversion cannot be performed.
fromDBid :: forall a. (HasCallStack, HasDBid a, Typeable a) => Int -> a
fromDBid i = case lookupDBid i of
Nothing -> panic $ "HasDBid " <> show (typeRep (Proxy :: Proxy a)) <> " not found or not implemented."
......
......@@ -51,7 +51,7 @@ trainList x y = (train x y) . trainList'
vecs2maps = map (IntMap.fromList . (zip [1..]) . Vec.toList)
predictList :: Model -> [Vec.Vector Double] -> IO [Maybe ListType]
predictList :: HasCallStack => Model -> [Vec.Vector Double] -> IO [Maybe ListType]
predictList (ModelSVM m _ _) vs = map (Just . fromDBid . round) <$> predict m vs
------------------------------------------------------------------------
......
......@@ -248,7 +248,7 @@ findNodesId r nt = tail
<$> map _dt_nodeId
<$> dbTree r nt
findNodesWithType :: RootId -> [NodeType] -> [NodeType] -> DBCmd err [DbTreeNode]
findNodesWithType :: HasCallStack => RootId -> [NodeType] -> [NodeType] -> DBCmd err [DbTreeNode]
findNodesWithType root target through =
filter isInTarget <$> dbTree root through
where
......@@ -282,8 +282,7 @@ toTree m =
-- m' ^.. at (Just $ _dt_nodeId root) . _Just . each . to (toTree' m')
toListOf (at (Just $ _dt_nodeId root) . _Just . each . to (toTree' m')) m'
toNodeTree :: DbTreeNode
-> NodeTree
toNodeTree :: HasCallStack => DbTreeNode -> NodeTree
toNodeTree (DbTreeNode nId tId _ n) = NodeTree n (fromDBid tId) nId
------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment