@@ -6,7 +6,6 @@ import Data.Array (catMaybes, range)
66import Data.Int (round , toNumber )
77import Data.Maybe (Maybe (..))
88import Data.Nullable (Nullable , toMaybe , toNullable )
9- import Data.Natural (Natural , intToNat , natToInt )
109import Data.Traversable (sequence )
1110import Effect (Effect )
1211import Web.DOM.Document (Document , documentElement )
@@ -97,18 +96,18 @@ singleNodeValue = map toMaybe <<< singleNodeValueInternal
9796foreign import invalidIteratorState :: XPathResult -> Boolean
9897
9998foreign import snapshotLengthInternal :: XPathResult -> Effect Number
100- snapshotLength :: XPathResult -> Effect Natural
101- snapshotLength = map (intToNat <<< round) <<< snapshotLengthInternal
99+ snapshotLength :: XPathResult -> Effect Int
100+ snapshotLength = map round <<< snapshotLengthInternal
102101
103102foreign import iterateNextInternal :: XPathResult -> Effect (Nullable Node )
104103iterateNext :: XPathResult -> Effect (Maybe Node )
105104iterateNext = map toMaybe <<< iterateNextInternal
106105
107106foreign import snapshotItemInternal ::
108107 XPathResult -> Number -> Effect (Nullable Node )
109- snapshotItem :: XPathResult -> Natural -> Effect (Maybe Node )
108+ snapshotItem :: XPathResult -> Int -> Effect (Maybe Node )
110109snapshotItem xpres ix = map toMaybe $
111- snapshotItemInternal xpres (toNumber $ natToInt $ ix)
110+ snapshotItemInternal xpres (toNumber ix)
112111
113112-- | High level wrapper around [snapshotItem](#v:snapshotItem)
114113-- | and [snapshotLength](#v:snapshotLength)
@@ -120,14 +119,14 @@ snapshot xpres = case snapMay of
120119 where
121120 snapTypMay = RT .res2SnapType $ resultType xpres
122121 snapMay = map snapshotInternal snapTypMay
123- nodeAtIdx :: Natural -> Effect (Maybe Node )
122+ nodeAtIdx :: Int -> Effect (Maybe Node )
124123 nodeAtIdx = snapshotItem xpres
125124 snapshotInternal :: RT.SnapshotType -> Effect (Array Node )
126125 snapshotInternal snapType = do
127126 nNodes <- snapshotLength xpres
128- nNodesInt <- pure $ natToInt nNodes
127+ nNodesInt <- pure nNodes
129128 -- nodeArray <- pure $ replicate nNodesInt _emptyNode
130- indices <- pure $ map intToNat $ range 0 (nNodesInt - 1 )
129+ indices <- pure $ range 0 (nNodesInt - 1 )
131130 nodeArray <- sequence $ map nodeAtIdx indices
132131 -- TODO: currently this is likely slow due to not using state
133132 pure $ catMaybes nodeArray
0 commit comments