module NLP.Minimorph.Util
( (<+>), tshow )
where
#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup
#endif
import qualified Data.Char as Char
import Data.Text (Text)
import qualified Data.Text as T
infixr 6 <+>
(<+>) :: Text -> Text -> Text
Text
t1 <+> :: Text -> Text -> Text
<+> Text
t2 | Text -> Bool
T.null Text
t1 = Text
t2
| Text -> Bool
T.null Text
t2 = Text
t1
| Char -> Bool
Char.isSpace (Text -> Char
T.last Text
t1) Bool -> Bool -> Bool
|| Char -> Bool
Char.isSpace (Text -> Char
T.head Text
t2) = Text
t1 Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t2
| Bool
otherwise = Text
t1 Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t2
tshow :: Show a => a -> Text
tshow :: a -> Text
tshow = String -> Text
T.pack (String -> Text) -> (a -> String) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String
forall a. Show a => a -> String
show