File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 11module Data.String.Regex.Flags where
22
33import Prelude
4+
5+ import Control.MonadPlus (guard )
6+
47import Data.Monoid (class Monoid )
8+ import Data.String (joinWith )
59
610type RegexFlagsRec =
711 { global :: Boolean
@@ -85,3 +89,26 @@ instance semigroupRegexFlags :: Semigroup RegexFlags where
8589
8690instance monoidRegexFlags :: Monoid RegexFlags where
8791 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