h$#       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~       Saferere A vendored  from *https://hackage.haskell.org/package/boring We only need Void instance.rere fmap absurd.Safe>rere A set of s.)We use range set, which works great with .rereEmpty character set.rereuniverse size universe1114112universe)CS.fromIntervalList [('\NUL','\1114111')]rereCheck whether  is .rereSize of .size $ fromIntervalList [('a','f'), ('0','9')]169length $ toList $ fromIntervalList [('a','f'), ('0','9')]16 rereSingleton character set. rere%Test whether character is in the set. rereInsert  into . rere Union of two s. rereIntersection of two srereComplement of a CharSetrereDifference of two s.rereMake ! from a list of characters, i.e. .rereConvert  to a list of characters i.e. .rereConvert to interval list&toIntervalList $ union "01234" "56789" [('0','9')]rereConvert from interval pairs.fromIntervalList []""'fromIntervalList [('a','f'), ('0','9')]"0123456789abcdef"fromIntervalList [('Z','A')]""rere"foobar" :: CharSet"abfor"    Safe|Safe567rereNames carry information used in pretty-printing, but otherwise they all  ual.rere is essentially .rereboundrerefree variable.rere Analogue of  for .rereSwap variables.rere3Make a name for derivative binding (adds subindex).Safe 567 +rere$Regular expression with fixed point.6rereMatch string by iteratively differentiating the regular expression.%This version is slow, consider using .7rereWhether the regular expression accepts empty string, or whether the formal language contains empty string. nullable EpsTruenullable (ch_ 'c')False8rere:Derivative of regular exression to respect of character. 8 c r is D_c(r).9rere: and 9 are slightly different implementations internally. We are interested in comparing whether either one is noticeably faster (no).:rere: and 9 are slightly different implementations internally. We are interested in comparing whether either one is noticeably faster (no).;rereSize of +. Counts constructors.<rereRe-apply smart constructors on +0 structure, thus potentially making it smaller.This function is slow.=rereVariable substitution.>rereSmart /, as it takes  argument.?rereConstruct literal  regex.@rereSmart 2.ArereSmart 4BrereSmart 5.CrereSmart 1.+31052-,./46789:;<=>?@ABC+31052-,./4>C@AB=?786<;:9=4C5SafepOrere Var (Left FZ),let b = Eps \/ ch_ 'b' <> Var (Left (FS FZ))let cfg = b ::: a ::: VNil[ begin{aligned} {mathit{b}} &= {varepsilon}cupmathtt{b}{mathit{a}} -- {mathit{a}} &= {varepsilon}cupmathtt{a}{mathit{b}} -- end{aligned}]^_^]_  Trustworthy '(d`rere Pretty-print + as LaTeX code.arereRun 6 variant, collect intermediate steps, and pretty-print that trace.brere Pretty-print ^ given the names.`ab`abSafe,+31052-,./4678;<=>?@ABCOPQRSTWXY\]^_`ab,+31052-,./4>C@AB=?78<;6\^]_WXYRSTOPQ`ab  Trustworthy '(#lrereSize of JSON grammar, 22.mrere3JSON recursive regular expression constructor from o. m = < (_ n o) The conversion doesn't optimize the resulting regular expression, but is relatively fast. size (cfgToRE jsonNames jsonCFG)232p is pre-calculated variant. size jsonRE205nrere Names of o productions.orere JSON grammarprere2Pre-calculated JSON grammar as regular expression. size jsonRE205See m for one constructed from o.lmnoplmnop  Trustworthy qrere9Demonstrates how various constructors are pretty printed.rrerematch ex1 "abab"Truematch ex1 "ababa"Falseex1Star (App (Ch "a") (Ch "b"))charClasses ex1fromList "\NULabc" showRef ex1size: 4"show: Star (App (Ch "a") (Ch "b")) null: TruematchR ex1 "abab"TruematchR ex1 "ababa"FalserunGen 43 (generate 10 20 ex1)"abababababababababab"runGen 44 (generate 10 20 ex1)"ababab"trerematch ex2 "aaa"True!Note: how "sharing" is preserved. showRef ex2size: 5)show: App (Star (Ch "a")) (Star (Ch "a")) null: True > matchR ex2 "aaa"TruerunGen 42 (generate 10 20 ex2)"aaaaaa"runGen 44 (generate 10 20 ex2) "aaaaaaaaaa"vrerematch ex3 "abab"Truematch ex3 "ababa"False showRef ex3size: 8show: Ref 0 (Alt Eps (App (Ch "a") (App (Ch "b") (Ref 0 <>)))) null: TruematchR ex3 "abab"TruematchR ex3 "ababa"FalserunGen 43 (generate 10 20 ex3) "abababab"runGen 44 (generate 10 20 ex3)"abab"xrerematch ex4 "aaaabbbb"True showRef ex4size: 8show: Ref 0 (Alt Eps (App (Ch "a") (App (Ref 0 <>) (Ch "b")))) null: TruematchR ex4 "aaaabbbb"TruerunGen 43 (generate 10 20 ex4)"ab"runGen 47 (generate 10 20 ex4) "aaaabbbb"zrerematch ex5 "abab"Truematch ex5 "ababa"False showRef ex5size: 8show: Ref 0 (Alt Eps (App (Ref 0 <>) (App (Ch "a") (Ch "b")))) null: TruematchR ex5 "abab"TruematchR ex5 "ababa"FalserunGen 43 (generate 10 20 ex5)"ab"runGen 51 (generate 10 20 ex5)"abab"|rereUsing fix-point operator: fix expr = "(" expr ")" | "1" | "2" | ... | "9" | expr "+" expr | expr "*" expr which in BNF is almost he same expr ::= "(" expr ")" | "1" | "2" | ... | "9" | expr "+" expr | expr "*" expr matchR ex6 "(1+2)*3"TruerunGen 43 (generate 5 5 ex6)"74501+(534*19450)*(99050)"rerematchR ex7 "12"TruematchR ex7 "(1+2)*3"TruecharClasses ex7fromList "\NUL()*+,0:"runGen 43 (generate 5 5 ex7)"(3431*((0337+5+070346+4))+76848+((4126+350875)*98769+308194+270+03118)+888*(95+90904)+(301069+7+715835)+2809)"qrstuvwxyz{|}~qrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABC+DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgdh i j k l m n o p q r s t u v w x y z { | } ~                        rere-0.2-8FOLuWekPbu23l89ylxZoc RERE.Absurd RERE.CharSetRERE.Var RERE.TypeRERE.CharClassesRERE.STRERE.RefRERE.GenRERE.CFG RERE.LaTeXRERE.Examples.JSON RERE.Examples RERE.TuplesREREmatchRmatchAbsurdabsurdvacuous $fAbsurdVoidCharSetemptyuniversenullsize singletonmemberinsertunion intersection complement differencefromListtoListtoIntervalListfromIntervalList $fShowCharSet$fIsStringCharSet $fEqCharSet $fOrdCharSetNameNVarBFunvarswapVarderivativeName $fIsStringVar$fIsStringName $fOrdName$fEqName $fShowName$fEqVar$fOrdVar $fShowVar $fFunctorVar $fFoldableVar$fTraversableVarRENullFullEpsChAppAltStarLetFixnullable derivative derivative2 derivative1compact>>>=ch_string_star_let_fix_\/ $fSemigroupRE $fArbitraryRE $fMonadRE$fApplicativeRE $fIsStringRE$fEqRE$fOrdRE$fShowRE $fFunctorRE $fFoldableRE$fTraversableRE CharClasses charClasses classOfCharRSTmatchST matchDebugST $fShowRST$fShowBoolExprRR matchDebugR$fShowRRgenerateCFGBaseCFGcfgToREputLatex putLatexTrace putLatexCFG $fMonoidPiece$fSemigroupPiece$fIsStringPiece$fEqNI$fOrdNI$fEqPrec $fOrdPrec $fEnumPrec $fShowPrecSizejsonRE' jsonNamesjsonCFGjsonREsyntaxExamplesex1ex1run1ex2ex2run1ex3ex3run1ex4ex4run1ex5ex5run1ex6ex6run1exCfgexCfgNex7ex7run1ex7run ex7parsec ex7parsecRunghc-prim GHC.TypesCharbaseGHC.BaseStringTripleTbimapfstOf3sndOf3trdOf3 GHC.ClassescompareEQ GHC.MaybeMaybe Data.Maybemaybe