{-# LANGUAGE TemplateHaskell #-}
module Text.Collate.CanonicalCombiningClass
( canonicalCombiningClass )
where
import Text.Collate.UnicodeData (genCanonicalCombiningClassMap)
import qualified Data.IntMap as M
import Data.Maybe (fromMaybe)
combiningClassMap :: M.IntMap Int
combiningClassMap :: IntMap Int
combiningClassMap = $(genCanonicalCombiningClassMap)
canonicalCombiningClass :: Int -> Int
canonicalCombiningClass :: Int -> Int
canonicalCombiningClass Int
cp
| Int
cp Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0x300 = Int
0
| Bool
otherwise = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
0 (Maybe Int -> Int)
-> (IntMap Int -> Maybe Int) -> IntMap Int -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IntMap Int -> Maybe Int
forall a. Int -> IntMap a -> Maybe a
M.lookup Int
cp (IntMap Int -> Int) -> IntMap Int -> Int
forall a b. (a -> b) -> a -> b
$! IntMap Int
combiningClassMap