module Data.Text.Normalize
(
NormalizationMode(..)
, normalize
) where
import Data.Text (Text)
import Data.Unicode.Internal.NormalizeStream ( DecomposeMode(..)
, stream
, unstream
, unstreamC)
import Data.Unicode.Types (NormalizationMode (..))
normalize :: NormalizationMode -> Text -> Text
normalize :: NormalizationMode -> Text -> Text
normalize NormalizationMode
mode =
case NormalizationMode
mode of
NormalizationMode
NFD -> (DecomposeMode -> Stream Char -> Text
unstream DecomposeMode
DecomposeNFD) (Stream Char -> Text) -> (Text -> Stream Char) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Stream Char
stream
NormalizationMode
NFKD -> (DecomposeMode -> Stream Char -> Text
unstream DecomposeMode
DecomposeNFKD) (Stream Char -> Text) -> (Text -> Stream Char) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Stream Char
stream
NormalizationMode
NFC -> (DecomposeMode -> Stream Char -> Text
unstreamC DecomposeMode
DecomposeNFD) (Stream Char -> Text) -> (Text -> Stream Char) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Stream Char
stream
NormalizationMode
NFKC -> (DecomposeMode -> Stream Char -> Text
unstreamC DecomposeMode
DecomposeNFKD) (Stream Char -> Text) -> (Text -> Stream Char) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Stream Char
stream