{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Retrie.Quantifiers
( Quantifiers
, emptyQs
, exceptQ
, isQ
, mkQs
, mkFSQs
, qList
, qSet
, unionQ
) where
import GHC.Exts (IsList(..))
import Retrie.GHC
instance IsList Quantifiers where
type Item Quantifiers = String
fromList :: [Item Quantifiers] -> Quantifiers
fromList = [FastString] -> Quantifiers
mkFSQs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map String -> FastString
mkFastString
toList :: Quantifiers -> [Item Quantifiers]
toList = forall a b. (a -> b) -> [a] -> [b]
map FastString -> String
unpackFS forall b c a. (b -> c) -> (a -> b) -> a -> c
. Quantifiers -> [FastString]
qList
newtype Quantifiers = Quantifiers
{ Quantifiers -> UniqSet FastString
qSet :: UniqSet FastString
}
instance Show Quantifiers where
show :: Quantifiers -> String
show Quantifiers
qs = String
"Quantifiers " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (Quantifiers -> [FastString]
qList Quantifiers
qs)
mkQs :: [RdrName] -> Quantifiers
mkQs :: [RdrName] -> Quantifiers
mkQs = [FastString] -> Quantifiers
mkFSQs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map RdrName -> FastString
rdrFS
mkFSQs :: [FastString] -> Quantifiers
mkFSQs :: [FastString] -> Quantifiers
mkFSQs = UniqSet FastString -> Quantifiers
Quantifiers forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Uniquable a => [a] -> UniqSet a
mkUniqSet
emptyQs :: Quantifiers
emptyQs :: Quantifiers
emptyQs = UniqSet FastString -> Quantifiers
Quantifiers forall a. UniqSet a
emptyUniqSet
isQ :: RdrName -> Quantifiers -> Bool
isQ :: RdrName -> Quantifiers -> Bool
isQ RdrName
r (Quantifiers UniqSet FastString
s) = forall a. Uniquable a => a -> UniqSet a -> Bool
elementOfUniqSet (RdrName -> FastString
rdrFS RdrName
r) UniqSet FastString
s
unionQ :: Quantifiers -> Quantifiers -> Quantifiers
unionQ :: Quantifiers -> Quantifiers -> Quantifiers
unionQ (Quantifiers UniqSet FastString
s) (Quantifiers UniqSet FastString
t) = UniqSet FastString -> Quantifiers
Quantifiers forall a b. (a -> b) -> a -> b
$ forall a. UniqSet a -> UniqSet a -> UniqSet a
unionUniqSets UniqSet FastString
s UniqSet FastString
t
exceptQ :: Quantifiers -> [RdrName] -> Quantifiers
exceptQ :: Quantifiers -> [RdrName] -> Quantifiers
exceptQ (Quantifiers UniqSet FastString
s) [RdrName]
rs =
UniqSet FastString -> Quantifiers
Quantifiers forall a b. (a -> b) -> a -> b
$ forall a. Uniquable a => UniqSet a -> [a] -> UniqSet a
delListFromUniqSet UniqSet FastString
s (forall a b. (a -> b) -> [a] -> [b]
map RdrName -> FastString
rdrFS [RdrName]
rs)
qList :: Quantifiers -> [FastString]
qList :: Quantifiers -> [FastString]
qList (Quantifiers UniqSet FastString
s) = forall elt. UniqSet elt -> [elt]
nonDetEltsUniqSet UniqSet FastString
s