about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-31 14:04:40 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-08-31 20:53:29 +0200
commit67e82e87582e586c1eaf573ac72a58302522f396 (patch)
tree15f9ad3a28b1a89dbd9ad75c54af646f9fb02cd6
parentd8e406c4f68e253f931031fdf1985f30fa1723e8 (diff)
refactor(EmojiTest): move emoji-test.txt parser into own module
-rw-r--r--emoji-generic.cabal2
-rw-r--r--src/Text/Emoji/DataFiles/EmojiTest.hs (renamed from src/Text/Emoji/DataFiles.hs)29
-rw-r--r--test/Main.hs2
3 files changed, 25 insertions, 8 deletions
diff --git a/emoji-generic.cabal b/emoji-generic.cabal
index 23362c0..4f2c976 100644
--- a/emoji-generic.cabal
+++ b/emoji-generic.cabal
@@ -17,7 +17,7 @@ extra-source-files:  README.md
 
 library
   exposed-modules:     Text.Emoji
-                     , Text.Emoji.DataFiles
+                     , Text.Emoji.DataFiles.EmojiTest
                      , Text.Emoji.Types
                      , Text.Emoji.String
                      , Text.Emoji.Text
diff --git a/src/Text/Emoji/DataFiles.hs b/src/Text/Emoji/DataFiles/EmojiTest.hs
index d99646a..ca54d6c 100644
--- a/src/Text/Emoji/DataFiles.hs
+++ b/src/Text/Emoji/DataFiles/EmojiTest.hs
@@ -1,11 +1,28 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-|
-  Module:      Text.Emoji.Data
-  Description:
+  Module:      Text.Emoji.DataFiles.EmojiTest
+  Description: Parsers and Utilities related to the @emoji-test.txt@ file.
+
+  This module can be utilized to parse the @emoji-test.txt@ data file
+  provided by the Unicode Consortium. This file contains a representation
+  of a more or less typical emoji keyboard which means you get:
+
+  * a list of valid emojis (qualified) plus unqualified ones,
+    emoji components, you can expect to find in the wild or
+    may want to input
+  * an organization of those into groups and subgroups (like in a keyboard)
 -}
 
 
-module Text.Emoji.DataFiles where
+module Text.Emoji.DataFiles.EmojiTest
+  ( -- * Representation of the parsed file
+    EmojiTest ()
+  , EmojiTestEntry (..)
+  , EmojiTestGroupLevel (..)
+    -- * Attoparsec parsers
+  , emojiVersionColumn
+  , emojiTestFile
+  ) where
 
 import Prelude hiding (takeWhile)
 
@@ -36,9 +53,6 @@ groupLevelText :: EmojiTestGroupLevel -> Text
 groupLevelText EmojiTestGroup = "group"
 groupLevelText EmojiTestSubgroup = "subgroup"
 
-notSpace :: Char -> Bool
-notSpace = notInClass " \t"
-
 notEol :: Char -> Bool
 notEol = notInClass "\n"
 
@@ -77,6 +91,8 @@ emojiTestGroup maxLevel = do
 
   pure $ Group EmojiTestGroup name groupEntries
 
+-- | Parses the textual representation of an 'EmojiVersion' as found
+--   in @emoji-test.txt@.
 emojiVersionColumn :: Parser EmojiVersion
 emojiVersionColumn = do
   _ <- char 'E'
@@ -120,6 +136,7 @@ emojiTestCommentLine = do
     then fail "group, not comment"
     else pure $ Comment text
 
+-- | Parses an entire @emoji-test.txt@ file or a subset of it.
 emojiTestFile :: Parser EmojiTest
 emojiTestFile = many1 $
   emojiTestGroup EmojiTestGroup <|> emojiTestEntryLine <|> emojiTestCommentLine
diff --git a/test/Main.hs b/test/Main.hs
index 76942e2..a375968 100644
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -9,7 +9,7 @@ import Test.Tasty.HUnit ((@?=), (@=?))
 import Test.SmallCheck.Series
 
 import Text.Emoji.Types
-import Text.Emoji.DataFiles
+import Text.Emoji.DataFiles.EmojiTest
 
 import Data.Attoparsec.Text (parseOnly)
 import Data.Either (fromRight)