Skip to content

Commit 82a502f

Browse files
pull functions out of where clauses
1 parent 3a24c8d commit 82a502f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Data/String/CodePoints.purs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ foreign import _count
129129

130130
countFallback :: (CodePoint -> Boolean) -> String -> Int
131131
countFallback p s = countTail p s 0
132-
where
133-
countTail :: (CodePoint -> Boolean) -> String -> Int -> Int
134-
countTail p' s' accum = case uncons s' of
135-
Just { head, tail } -> if p' head then countTail p' tail (accum + 1) else accum
136-
_ -> accum
132+
133+
countTail :: (CodePoint -> Boolean) -> String -> Int -> Int
134+
countTail p s accum = case uncons s of
135+
Just { head, tail } -> if p head then countTail p tail (accum + 1) else accum
136+
_ -> accum
137137

138138

139139
-- | Drops the given number of code points from the beginning of the string. If
@@ -263,10 +263,10 @@ foreign import _toCodePointArray
263263
-> Array CodePoint
264264

265265
toCodePointArrayFallback :: String -> Array CodePoint
266-
toCodePointArrayFallback s = unfoldr decode s
267-
where
268-
decode :: String -> Maybe (Tuple CodePoint String)
269-
decode s' = (\{ head, tail } -> Tuple head tail) <$> uncons s'
266+
toCodePointArrayFallback s = unfoldr unconsButWithTuple s
267+
268+
unconsButWithTuple :: String -> Maybe (Tuple CodePoint String)
269+
unconsButWithTuple s' = (\{ head, tail } -> Tuple head tail) <$> uncons s'
270270

271271

272272
-- | Returns a record with the first code point and the remaining code points

0 commit comments

Comments
 (0)