{-# LANGUAGE CPP              #-}
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.QuickCheck.Instances.Text () where

import Prelude ()
import Test.QuickCheck.Instances.CustomPrelude

import Test.QuickCheck

import qualified Data.Text      as T
import qualified Data.Text.Lazy as LT

-------------------------------------------------------------------------------
-- text
-------------------------------------------------------------------------------

instance Arbitrary T.Text where
    arbitrary :: Gen Text
arbitrary = String -> Text
T.pack (String -> Text) -> Gen String -> Gen Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen String
forall a. Arbitrary a => Gen a
arbitrary
    shrink :: Text -> [Text]
shrink Text
xs = String -> Text
T.pack (String -> Text) -> [String] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> [String]
forall a. Arbitrary a => a -> [a]
shrink (Text -> String
T.unpack Text
xs)

instance Arbitrary LT.Text where
    arbitrary :: Gen Text
arbitrary = String -> Text
LT.pack (String -> Text) -> Gen String -> Gen Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen String
forall a. Arbitrary a => Gen a
arbitrary
    shrink :: Text -> [Text]
shrink Text
xs = String -> Text
LT.pack (String -> Text) -> [String] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> [String]
forall a. Arbitrary a => a -> [a]
shrink (Text -> String
LT.unpack Text
xs)

instance CoArbitrary T.Text where
    coarbitrary :: Text -> Gen b -> Gen b
coarbitrary = String -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (String -> Gen b -> Gen b)
-> (Text -> String) -> Text -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack

instance CoArbitrary LT.Text where
    coarbitrary :: Text -> Gen b -> Gen b
coarbitrary = String -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (String -> Gen b -> Gen b)
-> (Text -> String) -> Text -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
LT.unpack

instance Function T.Text where
    function :: (Text -> b) -> Text :-> b
function = (Text -> String) -> (String -> Text) -> (Text -> b) -> Text :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap Text -> String
T.unpack String -> Text
T.pack

instance Function LT.Text where
    function :: (Text -> b) -> Text :-> b
function = (Text -> String) -> (String -> Text) -> (Text -> b) -> Text :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap Text -> String
LT.unpack String -> Text
LT.pack