@@ -20,6 +20,8 @@ module Data.UUID.Types.Internal
2020 ,toByteString
2121 ,fromString
2222 ,toString
23+ ,fromText
24+ ,toText
2325 ,fromWords
2426 ,toWords
2527 ,toList
@@ -61,6 +63,8 @@ import qualified Data.ByteString as B
6163import qualified Data.ByteString.Internal as BI
6264import qualified Data.ByteString.Lazy as BL
6365import qualified Data.ByteString.Unsafe as BU
66+import Data.Text (Text)
67+import qualified Data.Text as T
6468
6569import Data.UUID.Types.Internal.Builder
6670
@@ -307,6 +311,12 @@ toString (UUID w0 w1 w2 w3) = hexw w0 $ hexw' w1 $ hexw' w2 $ hexw w3 ""
307311 hexn :: Word32 -> Int -> Char
308312 hexn w r = intToDigit $ fromIntegral ((w `shiftR` r) .&. 0xf)
309313
314+fromText :: Text -> Maybe UUID
315+fromText = fromString . T.unpack
316+
317+toText :: UUID -> Text
318+toText = T.pack . toString
319+
310320-- | Convert a UUID into a hyphentated string using lower-case letters, packed
311321-- as ASCII bytes into `B.ByteString`.
312322--