module Data.Text.Normalize
(
NormalizationMode(..)
, normalize
) where
import Data.Text (Text)
import Data.Unicode.Types (NormalizationMode(..))
import Data.Unicode.Internal.NormalizeStream
( DecomposeMode(..)
, stream
, unstream
, unstreamC
)
normalize :: NormalizationMode -> Text -> Text
normalize :: NormalizationMode -> Text -> Text
normalize NormalizationMode
mode =
case NormalizationMode
mode of
NormalizationMode
NFD -> (DecomposeMode -> Stream Char -> Text
unstream DecomposeMode
Canonical) (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
Kompat) (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
Canonical) (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
Kompat) (Stream Char -> Text) -> (Text -> Stream Char) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Stream Char
stream