packages feed

sort-by-pinyin 2012.6.5 → 2014.5.19

raw patch · 3 files changed

+15/−13 lines, 3 filesdep +air-thdep ~airPVP ok

version bump matches the API change (PVP)

Dependencies added: air-th

Dependency ranges changed: air

API changes (from Hackage documentation)

Files

readme.md view
@@ -7,3 +7,6 @@     LT     > compare_chinese_string_by_pinyin "恶魔" "大天使"     GT+    > map show_pinyin "世界"+    [Just "shi4",Just "jie4"]+    
sort-by-pinyin.cabal view
@@ -1,5 +1,5 @@ Name:                 sort-by-pinyin-Version:              2012.6.5+Version:              2014.5.19 Build-type:           Simple Synopsis:             Sort simplified Chinese by PinYin Description:          Sort simplified Chinese by PinYin@@ -16,12 +16,13 @@ library   build-depends:      base >= 3 && < 99                     , text-                    , air+                    , air >= 2014.5.19+                    , air-th                     , containers                     , bytestring                     , air-extra-                    +   hs-source-dirs: src/-  exposed-modules:  +  exposed-modules:                     Text.SortByPinyin                     Text.SortByPinyinData
src/Text/SortByPinyin.hs view
@@ -1,4 +1,4 @@-module Text.SortByPinyin +module Text.SortByPinyin  (   pinyin_char_map@@ -12,7 +12,6 @@  import Air.Env import Prelude ()-import Air.TH import Air.Extra  import qualified Data.Char as Char@@ -32,22 +31,22 @@   pinyin_char_map :: Map.Map Char String-pinyin_char_map = +pinyin_char_map =   pinyins     .map (split "\t")     .map (take 2)     .reject (length > is_not 2)     .map (\(x:y:_) -> (x,y))     .map_fst hex_to_char-    .concatMap (\(x,y) -> -              case x of +    .concatMap (\(x,y) ->+              case x of                 Nothing -> []                 Just x' -> [(x',y)]                 )     .to_h  hex_to_char :: String -> Maybe Char-hex_to_char x = +hex_to_char x =   case Text.Read.hexadecimal (Text.pack x) of     Left _ -> Nothing     Right (int_value,_) -> Just - Char.chr int_value@@ -60,7 +59,7 @@   let x_pinyin = show_pinyin x       y_pinyin = show_pinyin y   in-  +   case x_pinyin of     Nothing -> compare x y     Just x_pinyin_string ->@@ -73,9 +72,8 @@ compare_chinese_string_by_pinyin :: String -> String -> Ordering compare_chinese_string_by_pinyin [] ys = LT compare_chinese_string_by_pinyin xs [] = GT-compare_chinese_string_by_pinyin (x:xs) (y:ys) = +compare_chinese_string_by_pinyin (x:xs) (y:ys) =   case compare_chinese_char_by_pinyin x y of     EQ -> compare_chinese_string_by_pinyin xs ys     LT -> LT     GT -> GT-