flip :: (a -> b -> <e> c) -> b -> a -> <e> c
flip f x y = f y x
+"Swaps the order of elements of a pair (2-tuple)."
swap :: (a,b) -> (b,a)
swap (x,y) = (y,x)
splitString :: String -> String -> [String]
splitString source pattern = arrayToList $ splitString_ source pattern
+"""
+`split pattern text` splits `text` around matches of the given regular expression `pattern`.
+
+This function works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
+
+The string "boo:and:foo", for example, yields the following results with these expressions:
+
+ Regex Result
+ : { "boo", "and", "foo" }
+ o { "b", "", ":and:f" }
+"""
split :: String -> String -> [String]
split pattern text = arrayToList $ splitString_ text pattern
(if i==0 then sb else sb << sep) <+ l!i
loop (i+1)
-"Joins the string representations of the list of values with the given separator."
+"""
+Joins the string representations of the list of values with the given separator.
+
+See [intercalate](#intercalate) for an alternative that works with Strings
+and doesn't escape its arguments.
+"""
joinWithSeparator :: Show a => String -> [a] -> String
joinWithSeparator separator values = runProc (
StringBuilder.toString $ printWithSeparator StringBuilder.new separator values)
+"""
+The intercalate function takes a String and a list of Strings
+and concatenates the list after interspersing the first argument
+between each element of the list.
+
+See also more generic [joinWithSeparator](#joinWithSeparator)
+which escapes its arguments using `show`.
+"""
intercalate :: String -> [String] -> String
intercalate separator strings = do
l = length strings