about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--emoji.cabal4
-rw-r--r--src/Text/Emoji/String.hs14
-rw-r--r--src/Text/Emoji/Text.hs18
3 files changed, 35 insertions, 1 deletions
diff --git a/emoji.cabal b/emoji.cabal
index 63c6041..011af52 100644
--- a/emoji.cabal
+++ b/emoji.cabal
@@ -17,7 +17,9 @@ cabal-version:       >=1.10
 
 library
   exposed-modules:     Text.Emoji.Types
-                       Text.Emoji.Data
+                     , Text.Emoji.Data
+                     , Text.Emoji.String
+                     , Text.Emoji.Text
   -- other-modules:       
   -- other-extensions:    
   build-depends:       base
diff --git a/src/Text/Emoji/String.hs b/src/Text/Emoji/String.hs
new file mode 100644
index 0000000..eb273f6
--- /dev/null
+++ b/src/Text/Emoji/String.hs
@@ -0,0 +1,14 @@
+{-|
+  Module:      Text.Emoji.String
+  Description: Emoji utilities for String
+-}
+
+module Text.Emoji.String where
+
+import           Text.Emoji.Types
+
+import           Codec.Binary.UTF8.Light (w2c)
+
+-- | Outputs a String for the given Emoji.
+fromEmoji :: Emoji -> String
+fromEmoji e = map w2c $ _code e
diff --git a/src/Text/Emoji/Text.hs b/src/Text/Emoji/Text.hs
new file mode 100644
index 0000000..d39a26d
--- /dev/null
+++ b/src/Text/Emoji/Text.hs
@@ -0,0 +1,18 @@
+{-|
+  Module:      Text.Emoji.Text
+  Description: Emoji utilities for Text
+-}
+
+
+module Text.Emoji.Text where
+
+import qualified Text.Emoji.String as S
+import           Text.Emoji.Types
+
+import           Data.Text         (Text (), pack)
+
+-- | Ouputs the given Emoji into Text.
+-- Uses the implementation of Text.Emoji.String
+-- since Text uses Chars, too.
+fromEmoji :: Emoji -> Text
+fromEmoji = pack . S.fromEmoji