@@ -90,11 +90,11 @@ parse src = do
9090 if err /= nullPtr then do
9191 bs <- BS.packCString =<< hexml_document_error doc
9292 hexml_document_free doc
93− return $ Left bs
93+ pure $ Left bs
9494 else do
9595 node <- hexml_document_node doc
9696 doc <- newForeignPtr hexml_document_free_funptr doc
97− return $ Right $ Node src0 doc node
97+ pure $ Right $ Node src0 doc node
9898
9999-- | Given a node, rerender it to something with an equivalent parse tree.
100100-- Mostly useful for debugging - if you want the real source document use 'outer' instead.
@@ -103,7 +103,7 @@ render (Node src doc n) = unsafePerformIO $ withForeignPtr doc $ \d -> do
103103 i <- hexml_node_render d n nullPtr 0
104104 res <- BS.create (fromIntegral i) $ \ptr -> void $ hexml_node_render d n (castPtr ptr) i
105105 touchBS src
106− return res
106+ pure res
107107
108108applyStr :: BS.ByteString -> Str -> BS.ByteString
109109applyStr bs Str{..} = BS.take (fromIntegral strLength) $ BS.drop (fromIntegral strStart) bs
@@ -118,7 +118,7 @@ attrPeek :: BS.ByteString -> ForeignPtr CDocument -> Ptr CAttr -> Attribute
118118attrPeek src doc a = unsafePerformIO $ withForeignPtr doc $ \_ -> do
119119 name <- applyStr src <$> peekElemOff (castPtr a) 0
120120 val <- applyStr src <$> peekElemOff (castPtr a) 1
121− return $ Attribute name val
121+ pure $ Attribute name val
122122
123123-- | Get the name of a node, e.g. @\<test /\>@ produces @\"test\"@.
124124name :: Node -> BS.ByteString
@@ -142,7 +142,7 @@ outer = nodeBS 2
142142contents :: Node -> [Either BS.ByteString Node]
143143contents n@(Node src _ _) = f (strStart inner) outers
144144 where
145− f i [] = string i (strEnd inner) ++ []
145+ f i [] = string i (strEnd inner)
146146 f i ((x, n):xs) = string i (strStart x) ++ Right n : f (strEnd x) xs
147147
148148 string start end | start == end = []
@@ -156,7 +156,7 @@ children (Node src doc n) = unsafePerformIO $ withForeignPtr doc $ \d ->
156156 alloca $ \count -> do
157157 res <- hexml_node_children d n count
158158 count <- fromIntegral <$> peek count
159− return [Node src doc $ plusPtr res $ i*szNode | i <- [0..count-1]]
159+ pure [Node src doc $ plusPtr res $ i*szNode | i <- [0..count-1]]
160160
161161-- | Get the attributes of this node.
162162attributes :: Node -> [Attribute]
@@ -164,7 +164,7 @@ attributes (Node src doc n) = unsafePerformIO $ withForeignPtr doc $ \d ->
164164 alloca $ \count -> do
165165 res <- hexml_node_attributes d n count
166166 count <- fromIntegral <$> peek count
167− return [attrPeek src doc $ plusPtr res $ i*szAttr | i <- [0..count-1]]
167+ pure [attrPeek src doc $ plusPtr res $ i*szAttr | i <- [0..count-1]]
168168
169169-- | Get the direct children of this node which have a specific name.
170170-- A more efficient version of:
@@ -177,7 +177,7 @@ childrenBy (Node src doc n) str = go nullPtr
177177 BS.unsafeUseAsCStringLen str $ \(bs, len) -> do
178178 r <- hexml_node_child d n old bs $ fromIntegral len
179179 touchBS src
180− return $ if r == nullPtr then [] else Node src doc r : go r
180+ pure $ if r == nullPtr then [] else Node src doc r : go r
181181
182182-- | Get the first attribute of this node which has a specific name, if there is one.
183183-- A more efficient version of:
@@ -188,7 +188,7 @@ attributeBy (Node src doc n) str = unsafePerformIO $ withForeignPtr doc $ \d ->
188188 BS.unsafeUseAsCStringLen str $ \(bs, len) -> do
189189 r <- hexml_node_attribute d n bs $ fromIntegral len
190190 touchBS src
191− return $ if r == nullPtr then Nothing else Just $ attrPeek src doc r
191+ pure $ if r == nullPtr then Nothing else Just $ attrPeek src doc r
192192
193193-- | Find the starting location of a node, the @<@ character.
194194-- The first character will be reported as @(line 1,column 1)@, because thats