stripPrefix package:jsaddle

O(n) Return the suffix of the second string if its prefix matches the entire first string. Examples:
stripPrefix "foo" "foobar" == Just "bar"
stripPrefix ""    "baz"    == Just "baz"
stripPrefix "foo" "quux"   == Nothing
This is particularly useful with the ViewPatterns extension to GHC, as follows:
{-# LANGUAGE ViewPatterns #-}
import Data.Text as T

fnordLength :: JSString -> Int
fnordLength (stripPrefix "fnord" -> Just suf) = T.length suf
fnordLength _                                 = -1