-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifier.hs
More file actions
36 lines (28 loc) · 761 Bytes
/
Modifier.hs
File metadata and controls
36 lines (28 loc) · 761 Bytes
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
module GameEngine.ConfigReader.Modifier where
import Data.Either
-- A negative modifier word.
data NegativeModifier
= NNo
| NNot
deriving (Show,Eq)
-- A positive modifier word.
data PositiveModifier
= PIs
| PHas
| PHave
| PDoes
| PUses
| PUsing
| PSet
| PExists
deriving (Show,Eq)
-- Either a negative or a positive modifier.
type Modifier = Either NegativeModifier PositiveModifier
-- A list of Modifiers.
type Modifiers = [Modifier]
-- Does a list of modifiers indicate the positive option?
modifiersPositive :: Modifiers -> Bool
modifiersPositive = (== 0) . (`mod` 2) . length . lefts
-- Does a list of modifiers indicate the negative option?
modifiersNegative :: Modifiers -> Bool
modifiersNegative = not . modifiersPositive