~alcinnz/fontconfig-pure

ref: dfce3326f7f5b2367df56675e92742b3d5f7fbc3 fontconfig-pure/lib/Graphics/Text/Font/Choose/StrSet.hs -rw-r--r-- 651 bytes
dfce3326 — Adrian Cochrane Test @font-face parsing. 4 months ago
                                                                                
dbefdc06 Adrian Cochrane
58463bff Adrian Cochrane
4da6f787 Adrian Cochrane
40a431c7 Adrian Cochrane
4da6f787 Adrian Cochrane
40a431c7 Adrian Cochrane
4da6f787 Adrian Cochrane
40a431c7 Adrian Cochrane
58463bff Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- | A set of strings to match.
module Graphics.Text.Font.Choose.StrSet(StrSet(..), module S, validStrSet) where

import Data.Set (Set)
import qualified Data.Set as S

import Data.MessagePack (MessagePack(..))
import Test.QuickCheck (Arbitrary(..))

newtype StrSet = StrSet { unStrSet :: Set String } deriving (Eq, Show, Read)

instance MessagePack StrSet where
    toObject = toObject . S.toList . unStrSet
    fromObject msg = StrSet <$> S.fromList <$> fromObject msg
instance Arbitrary StrSet where
    arbitrary = StrSet <$> S.map (filter (/= '\0')) <$> arbitrary

validStrSet :: StrSet -> Bool
validStrSet (StrSet self) = notElem '\0' `all` self