Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 ghcjs-dom。如何从节点数组中过滤元素?
import GHCJS.DOM.Types nodesToElements :: [Node] -> [Element] nodesToElements = ??
或者
nodesToElements :: [Node] -> IO [Element] nodesToElements = ??
import GHCJS.DOM.Types import Data.Maybe (mapMaybe) nodeToElement :: Node -> Maybe Element nodeToElement node = if node `isA` gTypeElement then Just $ castToElement node else Nothing nodesToElements :: [Node] -> [Element] nodesToElements = mapMaybe nodeToElement