diff options
author | lukasepple <git@lukasepple.de> | 2015-11-03 13:33:53 +0100 |
---|---|---|
committer | lukasepple <git@lukasepple.de> | 2015-11-03 13:33:53 +0100 |
commit | e1647328a634e44dbcbd84a53db045a788cdf051 (patch) | |
tree | bb4ebeb8fdd8b01763f57979a39d48203b93b3ab | |
parent | 567e21d7ab6ac5e2cd9a55b86deb9030d83d367e (diff) |
Add basic emoji utilities for Text and String
Actually it's just fromEmoji. There is of course more to follow.
-rw-r--r-- | emoji.cabal | 4 | ||||
-rw-r--r-- | src/Text/Emoji/String.hs | 14 | ||||
-rw-r--r-- | src/Text/Emoji/Text.hs | 18 |
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 |