1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

s/return/pure

This commit is contained in:
joshvera 2016-05-26 14:56:38 -04:00
parent e3559641ff
commit b3842692cd

View File

@ -54,11 +54,11 @@ documentToTerm constructor document contents = alloca $ \ root -> do
name <- ts_node_p_name node document
name <- peekCString name
count <- ts_node_p_named_child_count node
children <- mapM (alloca . getChild node) $ take (fromIntegral count) [0..]
children <- traverse (alloca . getChild node) $ take (fromIntegral count) [0..]
-- Note: The strict application here is semantically important. Without it, we may not evaluate the range until after weve exited the scope that `node` was allocated within, meaning `alloca` will free it & other stack data may overwrite it.
range <- return $! Range { start = fromIntegral $ ts_node_p_start_char node, end = fromIntegral $ ts_node_p_end_char node }
range <- pure $! Range { start = fromIntegral $ ts_node_p_start_char node, end = fromIntegral $ ts_node_p_end_char node }
return $! constructor contents range name children
pure $! constructor contents range name children
getChild node n out = do
_ <- ts_node_p_named_child node n out
toTerm out