File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
module Data.String.Regex.Flags where
2
2
3
3
import Prelude
4
+
5
+ import Control.MonadPlus (guard )
6
+
4
7
import Data.Monoid (class Monoid )
8
+ import Data.String (joinWith )
5
9
6
10
type RegexFlagsRec =
7
11
{ global :: Boolean
@@ -85,3 +89,26 @@ instance semigroupRegexFlags :: Semigroup RegexFlags where
85
89
86
90
instance monoidRegexFlags :: Monoid RegexFlags where
87
91
mempty = noFlags
92
+
93
+ instance eqRegexFlags :: Eq RegexFlags where
94
+ eq (RegexFlags x) (RegexFlags y)
95
+ = x.global == y.global
96
+ && x.ignoreCase == y.ignoreCase
97
+ && x.multiline == y.multiline
98
+ && x.sticky == y.sticky
99
+ && x.unicode == y.unicode
100
+
101
+ instance showRegexFlags :: Show RegexFlags where
102
+ show (RegexFlags flags) =
103
+ let
104
+ usedFlags =
105
+ []
106
+ <> (guard flags.global $> " global" )
107
+ <> (guard flags.ignoreCase $> " ignoreCase" )
108
+ <> (guard flags.multiline $> " multiline" )
109
+ <> (guard flags.sticky $> " sticky" )
110
+ <> (guard flags.unicode $> " unicode" )
111
+ in
112
+ if usedFlags == []
113
+ then " noFlags"
114
+ else " (" <> joinWith " <> " usedFlags <> " )"
You can’t perform that action at this time.
0 commit comments