Skip to content

Instantly share code, notes, and snippets.

@tonymorris
Created June 7, 2024 01:27
Show Gist options
  • Save tonymorris/80b1b11b31a90ccfdb6bbb4deaa5eea9 to your computer and use it in GitHub Desktop.
Save tonymorris/80b1b11b31a90ccfdb6bbb4deaa5eea9 to your computer and use it in GitHub Desktop.
-- |
--
-- >>> parse (search (string "abc")) "test" ""
-- Right []
--
-- >>> parse (search (string "abc")) "test" " abc def abc "
-- Right ["abc","abc"]
search ::
Stream s m Char =>
ParsecT s u m a
-> ParsecT s u m [a]
search p =
let ps = search p
in (:) <$> try p <*> ps <|>
try (anyChar *> ps) <|>
pure []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment