 
  @return [Mention]: A new mention array
  */
-internal func remove(_ mentionsToRemove: [Mention]) -> (inout [Mention]) -> Void {
+internal func remove(_ mentionsToRemove: [Mention]) -> ([Mention]) -> [Mention] {
     return { mentions in
-        mentions = mentions.filter { !mentionsToRemove.contains($0)
-        }
+        mentions.filter { !mentionsToRemove.contains($0) }
     }
 }
 


 @return [Mention]: A new mention array
 */
internal func add(_ mention: CreateMention, spaceAfterMention: Bool, at range: NSRange) -> (inout [Mention]) -> Void {
    return { mentions in
        let adjustedRange = range.adjustLength(for: mention.name)
        mentions |> adjusted(forTextChangeAt: range,
                             text: mention.mentionName(with: spaceAfterMention))
        mentions |> insert([(mention, adjustedRange)])
    }
}


 @return [Mention]: A new mention array
 */
internal func insert(_ newMentions: [(CreateMention, NSRange)]) -> ([Mention]) -> [Mention] {
    return { mentions in
        mentions + newMentions.map { createMention, range in
            Mention(range: range, object: createMention)
        }
    }
