-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathExtScheme.hs
39 lines (31 loc) · 1.12 KB
/
ExtScheme.hs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{-# LANGUAGE Safe #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
-- Module : Language.Haskell.Exts.ExtScheme
-- Copyright : (c) Niklas Broberg 2009
-- License : BSD-style (see the file LICENSE.txt)
--
-- Maintainer : Niklas Broberg, [email protected]
-- Stability : stable
-- Portability : portable
--
-- Internal scheme for handling extensions in a
-- convenient fashion.
--
-----------------------------------------------------------------------------
module Language.Haskell.Exts.ExtScheme where
import Language.Haskell.Exts.Extension
data ExtScheme = Any [KnownExtension] | All [KnownExtension]
deriving (Eq,Show)
type MExtScheme = Maybe ExtScheme
class Enabled a where
isEnabled :: a -> [KnownExtension] -> Bool
instance Enabled KnownExtension where
isEnabled = elem
instance Enabled ExtScheme where
isEnabled (Any exts) enabled = any (`elem` enabled) exts
isEnabled (All exts) enabled = all (`elem` enabled) exts
instance Enabled a => Enabled (Maybe a) where
isEnabled Nothing = const True
isEnabled (Just a) = isEnabled a