File: QuickCheckUtils.hs

package info (click to toggle)
haskell-text-icu 0.7.0.1-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 348 kB
  • sloc: haskell: 804; ansic: 524; makefile: 4
file content (25 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module QuickCheckUtils () where

import Control.Applicative ((<$>))
import Control.DeepSeq (NFData(..))
import Data.Text.ICU (Collator, LocaleName(..), NormalizationMode(..))
import Data.Text.ICU.Break (available)
import Test.QuickCheck (Arbitrary(..), elements)
import qualified Data.Text as T
import qualified Data.Text.ICU as I

instance Arbitrary T.Text where
    arbitrary = T.pack `fmap` arbitrary
    shrink = map T.pack . shrink . T.unpack

instance Arbitrary LocaleName where
    arbitrary = elements (Root:available)

instance Arbitrary NormalizationMode where
    arbitrary = elements [None ..FCD]

instance Arbitrary Collator where
    arbitrary = I.collator <$> arbitrary