Revision 4651c69f src/Ganeti/BasicTypes.hs
b/src/Ganeti/BasicTypes.hs | ||
---|---|---|
41 | 41 |
, goodMatchPriority |
42 | 42 |
, prefixMatch |
43 | 43 |
, compareNameComponent |
44 |
, ListSet(..) |
|
45 |
, emptyListSet |
|
44 | 46 |
) where |
45 | 47 |
|
46 | 48 |
import Control.Applicative |
... | ... | |
48 | 50 |
import Control.Monad.Trans |
49 | 51 |
import Data.Function |
50 | 52 |
import Data.List |
53 |
import Data.Set (Set) |
|
54 |
import qualified Data.Set as Set (empty) |
|
55 |
import Text.JSON (JSON) |
|
56 |
import qualified Text.JSON as JSON (readJSON, showJSON) |
|
51 | 57 |
|
52 | 58 |
-- | Generic monad for our error handling mechanisms. |
53 | 59 |
data GenericResult a b |
... | ... | |
224 | 230 |
-> LookupResult -- ^ Result of the lookup |
225 | 231 |
lookupName l s = foldr (chooseLookupResult s) |
226 | 232 |
(LookupResult FailMatch s) l |
233 |
|
|
234 |
-- | Wrapper for a Haskell 'Set' |
|
235 |
-- |
|
236 |
-- This type wraps a 'Set' and it is used in the Haskell to Python |
|
237 |
-- opcode generation to transform a Haskell 'Set' into a Python 'list' |
|
238 |
-- without duplicate elements. |
|
239 |
newtype ListSet a = ListSet { unListSet :: Set a } |
|
240 |
deriving (Eq, Show) |
|
241 |
|
|
242 |
instance (Ord a, JSON a) => JSON (ListSet a) where |
|
243 |
showJSON = JSON.showJSON . unListSet |
|
244 |
readJSON = liftM ListSet . JSON.readJSON |
|
245 |
|
|
246 |
emptyListSet :: ListSet a |
|
247 |
emptyListSet = ListSet Set.empty |
Also available in: Unified diff