{-# OPTIONS_HADDOCK hide #-}
module Language.Haskell.Exts.ExtScheme where
import Language.Haskell.Exts.Extension
data ExtScheme = Any [KnownExtension] | All [KnownExtension]
deriving (ExtScheme -> ExtScheme -> Bool
(ExtScheme -> ExtScheme -> Bool)
-> (ExtScheme -> ExtScheme -> Bool) -> Eq ExtScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExtScheme -> ExtScheme -> Bool
$c/= :: ExtScheme -> ExtScheme -> Bool
== :: ExtScheme -> ExtScheme -> Bool
$c== :: ExtScheme -> ExtScheme -> Bool
Eq,Int -> ExtScheme -> ShowS
[ExtScheme] -> ShowS
ExtScheme -> String
(Int -> ExtScheme -> ShowS)
-> (ExtScheme -> String)
-> ([ExtScheme] -> ShowS)
-> Show ExtScheme
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExtScheme] -> ShowS
$cshowList :: [ExtScheme] -> ShowS
show :: ExtScheme -> String
$cshow :: ExtScheme -> String
showsPrec :: Int -> ExtScheme -> ShowS
$cshowsPrec :: Int -> ExtScheme -> ShowS
Show)
type MExtScheme = Maybe ExtScheme
class Enabled a where
isEnabled :: a -> [KnownExtension] -> Bool
instance Enabled KnownExtension where
isEnabled :: KnownExtension -> [KnownExtension] -> Bool
isEnabled = KnownExtension -> [KnownExtension] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem
instance Enabled ExtScheme where
isEnabled :: ExtScheme -> [KnownExtension] -> Bool
isEnabled (Any [KnownExtension]
exts) [KnownExtension]
enabled = (KnownExtension -> Bool) -> [KnownExtension] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (KnownExtension -> [KnownExtension] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [KnownExtension]
enabled) [KnownExtension]
exts
isEnabled (All [KnownExtension]
exts) [KnownExtension]
enabled = (KnownExtension -> Bool) -> [KnownExtension] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (KnownExtension -> [KnownExtension] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [KnownExtension]
enabled) [KnownExtension]
exts
instance Enabled a => Enabled (Maybe a) where
isEnabled :: Maybe a -> [KnownExtension] -> Bool
isEnabled Maybe a
Nothing = Bool -> [KnownExtension] -> Bool
forall a b. a -> b -> a
const Bool
True
isEnabled (Just a
a) = a -> [KnownExtension] -> Bool
forall a. Enabled a => a -> [KnownExtension] -> Bool
isEnabled a
a