@@ -173,17 +173,24 @@ takeWhile p s = take (count p s) s
173173dropWhile :: (Char -> Boolean ) -> String -> String
174174dropWhile p s = drop (count p s) s
175175
176- -- | Returns the substring at indices [begin, end).
176+ -- | Returns the substring at indices ` [begin, end)` .
177177-- | If either index is negative, it is normalised to `length s - index`,
178- -- | where `s` is the input string. An empty string is returned if either
178+ -- | where `s` is the input string. `Nothing` is returned if either
179179-- | index is out of bounds or if `begin > end` after normalisation.
180180-- |
181181-- | ```purescript
182- -- | slice 0 1 "purescript" == "p"
183- -- | slice 3 6 "purescript" == "ecr"
184- -- | slice -4 -1 "purescript" == "rip"
182+ -- | slice 0 1 "purescript" == Just "p"
183+ -- | slice 3 6 "purescript" == Just "ecr"
184+ -- | slice -4 -1 "purescript" == Just "rip"
185+ -- | slice -4 3 "purescript" == Nothing
185186-- | ```
186- foreign import slice :: Int -> Int -> String -> String
187+ slice :: Int -> Int -> String -> Maybe String
188+ slice = _slice Just Nothing
189+
190+ foreign import _slice
191+ :: (forall a . a -> Maybe a )
192+ -> (forall a . Maybe a )
193+ -> Int -> Int -> String -> Maybe String
187194
188195-- | If the string starts with the given prefix, return the portion of the
189196-- | string left after removing it, as a Just value. Otherwise, return Nothing.
0 commit comments