Remove an unused type synonim
[ganeti-local] / Ganeti / HTools / Types.hs
1 {-| Some common types.
2
3 -}
4
5 module Ganeti.HTools.Types
6     where
7
8 -- | The instance index type
9 type Idx = Int
10
11 -- | The node index type
12 type Ndx = Int
13
14 -- | The type used to hold name-to-idx mappings
15 type NameAssoc = [(String, Int)]
16
17 {-|
18
19 This is similar to the JSON library Result type - *very* similar, but
20 we want to use it in multiple places, so we abstract it into a
21 mini-library here
22
23 -}
24 data Result a
25     = Bad String
26     | Ok a
27     deriving (Show)
28
29 instance Monad Result where
30     (>>=) (Bad x) _ = Bad x
31     (>>=) (Ok x) fn = fn x
32     return = Ok
33     fail = Bad
34
35 -- | A generic class for items that have names and indices
36 class Element a where
37     nameOf  :: a -> String
38     idxOf   :: a -> Int
39     setName :: a -> String -> a
40     setIdx  :: a -> Int -> a