This works:
{-# LANGUAGE OverloadedStrings #-}
myFunc :: Text -> String
myFunc "" = "nothing"
myFunc other = "something!"
Without the OverloadedStrings
extension however, ""
is of type String
so it doesn't compile. Using a function like myFunc (pack "")
is not allowed in patterns.
Haskell Bytestrings: How to pattern match? contains some suggestions that should work, however in this case I'm wondering if there is something special about the fact that it works with OverloadedStrings
that would allow a better way?