breakOn

O(n+m) Find the first instance of needle (which must be non-null) in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match. Examples:
>>> breakOn "::" "a::b::c"
("a","::b::c")
>>> breakOn "/" "foobar"
("foobar","")
Laws:
append prefix match == haystack
where (prefix, match) = breakOn needle haystack
If you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use breakOnAll instead, as it has lower startup overhead. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).
O(n+m) Find the first instance of needle (which must be non-null) in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match. Examples:
breakOn "::" "a::b::c" ==> ("a", "::b::c")
breakOn "/" "foobar"   ==> ("foobar", "")
Laws:
append prefix match == haystack
where (prefix, match) = breakOn needle haystack
If you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use breakOnAll instead, as it has lower startup overhead. This function is strict in its first argument, and lazy in its second. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).
Find the first instance of needle in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match. If you want the remainder without the match, use stripInfix.
breakOn "::" "a::b::c" == ("a", "::b::c")
breakOn "/" "foobar"   == ("foobar", "")
\needle haystack -> let (prefix,match) = breakOn needle haystack in prefix ++ match == haystack
O(n+m) Find the first instance of needle (which must be non-null) in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match. Examples:
breakOn "::" "a::b::c" ==> ("a", "::b::c")
breakOn "/" "foobar"   ==> ("foobar", "")
Laws:
append prefix match == haystack
where (prefix, match) = breakOn needle haystack
If you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use breakOnAll instead, as it has lower startup overhead. This function is strict in its first argument, and lazy in its second. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).
O(n+m) Find the first instance of needle (which must be non-null) in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match. Examples:
>>> breakOn "::" "a::b::c"
("a","::b::c")
>>> breakOn "/" "foobar"
("foobar","")
Laws:
append prefix match == haystack
where (prefix, match) = breakOn needle haystack
If you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use breakOnAll instead, as it has lower startup overhead. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).
Improper lens that splits at the first occurrence of the pattern.
O(n+m) Find the first instance of needle (which must be non-null) in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match. Examples:
breakOn "::" "a::b::c" ==> ("a", "::b::c")
breakOn "/" "foobar"   ==> ("foobar", "")
Laws:
append prefix match == haystack
where (prefix, match) = breakOn needle haystack
If you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use breakOnAll instead, as it has lower startup overhead. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).
breakOn pattern target splits target at the first occurrence of pattern. If the pattern does not occur in the target, the second component of the result is empty, otherwise it starts with pattern. If the pattern is empty, the first component is empty. For a non-empty pattern, the first component is generated lazily, thus the first parts of it can be available before the pattern has been found or determined to be absent.
uncurry append . breakOn pattern = id
breakOn pattern target splits target at the first occurrence of pattern. If the pattern does not occur in the target, the second component of the result is empty, otherwise it starts with pattern. If the pattern is empty, the first component is empty.
uncurry append . breakOn pattern = id
Drops the separator byte
Similar to the function of the same name in the text package. breakOn needles haystack finds the first instance of an element of needles in haystack. The first component of the result is the needle tag, the second component is the prefix of haystack before the matched needle, the third component is the remainder of the haystack after the needle..
Similar to the function of the same name in the text package. breakOn needles haystack finds the first instance of an element of needles in haystack. The first component of the result is the needle tag, the second component is the prefix of haystack before the matched needle, the third component is the remainder of the haystack after the needle..
O(n+m) Find all non-overlapping instances of needle in haystack. Each element of the returned list consists of a pair:
  • The entire string prior to the kth match (i.e. the prefix)
  • The kth match, followed by the remainder of the string
Examples:
>>> breakOnAll "::" ""
[]
>>> breakOnAll "/" "a/b/c/"
[("a","/b/c/"),("a/b","/c/"),("a/b/c","/")]
In (unlikely) bad cases, this function's time complexity degrades towards O(n*m). The needle parameter may not be empty.
O(n+m) Similar to breakOn, but searches from the end of the string. The first element of the returned tuple is the prefix of haystack up to and including the last match of needle. The second is the remainder of haystack, following the match.
>>> breakOnEnd "::" "a::b::c"
("a::b::","c")
O(n+m) Find all non-overlapping instances of needle in haystack. Each element of the returned list consists of a pair:
  • The entire string prior to the kth match (i.e. the prefix)
  • The kth match, followed by the remainder of the string
Examples:
breakOnAll "::" ""
==> []
breakOnAll "/" "a/b/c/"
==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
This function is strict in its first argument, and lazy in its second. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m). The needle parameter may not be empty.
O(n+m) Similar to breakOn, but searches from the end of the string. The first element of the returned tuple is the prefix of haystack up to and including the last match of needle. The second is the remainder of haystack, following the match.
breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")
Similar to breakOn, but searches from the end of the string. The first element of the returned tuple is the prefix of haystack up to and including the last match of needle. The second is the remainder of haystack, following the match.
breakOnEnd "::" "a::b::c" == ("a::b::", "c")
O(n+m) Find all non-overlapping instances of needle in haystack. Each element of the returned list consists of a pair:
  • The entire string prior to the kth match (i.e. the prefix)
  • The kth match, followed by the remainder of the string
Examples:
breakOnAll "::" ""
==> []
breakOnAll "/" "a/b/c/"
==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
This function is strict in its first argument, and lazy in its second. In (unlikely) bad cases, this function's time complexity degrades towards O(n*m). The needle parameter may not be empty.
O(n+m) Similar to breakOn, but searches from the end of the string. The first element of the returned tuple is the prefix of haystack up to and including the last match of needle. The second is the remainder of haystack, following the match.
breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")
O(n+m) Find all non-overlapping instances of needle in haystack. Each element of the returned list consists of a pair:
  • The entire string prior to the kth match (i.e. the prefix)
  • The kth match, followed by the remainder of the string
Examples:
>>> breakOnAll "::" ""
[]
>>> breakOnAll "/" "a/b/c/"
[("a","/b/c/"),("a/b","/c/"),("a/b/c","/")]
In (unlikely) bad cases, this function's time complexity degrades towards O(n*m). The needle parameter may not be empty.
O(n+m) Similar to breakOn, but searches from the end of the string. The first element of the returned tuple is the prefix of haystack up to and including the last match of needle. The second is the remainder of haystack, following the match.
>>> breakOnEnd "::" "a::b::c"
("a::b::","c")
O(n+m) Find all non-overlapping instances of needle in haystack. Each element of the returned list consists of a pair:
  • The entire string prior to the kth match (i.e. the prefix)
  • The kth match, followed by the remainder of the string
Examples:
breakOnAll "::" ""
==> []
breakOnAll "/" "a/b/c/"
==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
In (unlikely) bad cases, this function's time complexity degrades towards O(n*m). The needle parameter may not be empty.