úÎ!… üF      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEBSD3$Brent Yorgey <byorgey@cis.upenn.edu> experimentalnon-portable (see .cabal)None&'-.;=?HMSUVX¾first-class-patterns"Concatenation of lists. Instances: Ttype instance Nil :++: xs = xs type instance (h:*:t) :++: xs = h :*: (t :++: xs) BSD3$Brent Yorgey <byorgey@cis.upenn.edu> experimentalnon-portable (see .cabal)None&'-.;=>?HMSUVX#Ffirst-class-patternsThe API presented by !Data.Pattern.Base.Difference.GADT and #Data.Pattern.Base.Difference.Coerce. An instance of Fb is a type which converts an inductively-defined type to one with an efficient append operation.Gfirst-class-patternsconstructs the empty d t.Hfirst-class-patterns appends two d ts.Ifirst-class-patterns3given a "cons" operation, constructs the singleton d t.Jfirst-class-patterns given a "nil" value, "runs" the d t.KFGHIJBSD3$Brent Yorgey <byorgey@cis.upenn.edu> experimentalnon-portable (see .cabal)None&'-.;=?HMSUVX3first-class-patternsTuples with types given by xs.first-class-patternsCurried functions. We have /Fun '[x1, ..., xn] r = x1 -> ... -> xn -> rfirst-class-patternsThe empty tuplefirst-class-patternsThe singleton tuple first-class-patternsConcatenation of tuples. first-class-patterns2Runs a tuple by applying it to a curried function.Lfirst-class-patternsORuns a tuple by applying it to an uncurried function expecting nested pairs.   BSD3$Brent Yorgey <byorgey@cis.upenn.edu> experimentalnon-portable (see .cabal)None&'-.;=?HMSUVX1—first-class-patterns6Pattern-match clauses. Typically something of the form pattern  functionPwhere the function takes one argument for each variable bound by the pattern. Clauses can be constructed with () , run with tryMatch, and manipulated by the M and N" instances. In particular, the () operator from the O9 class is the way to list multiple cases in a pattern.first-class-patterns3Extract the underlying computation constituting a D. This function is not intended to be used directly; instead, see match, tryMatch, mmatch, and elim from Data.Pattern.Common.first-class-patterns"The pattern type. A value of type Pattern vars a. is a pattern which matches values of type a: and binds variables with types given by the type-list vars!. For example, something of type !Pattern (a :*: c :*: Nil) (a,b,c)Iis a pattern which matches against a triple and binds values of types a and c3. (A pattern of this type can be constructed as tup3 var __ var.)9Many "normal" patterns can be conveniently defined using mk0, mk1, mk2 , and so on.first-class-patterns Construct a o from a pattern and a function which takes one argument for each variable bound by the pattern. For example, gpair __ nothing ->> 3 pair var nothing ->> \x -> x + 3 pair var (just var) ->> \x y -> x + y + 3 4BSD3$Brent Yorgey <byorgey@cis.upenn.edu> experimentalnon-portable (see .cabal)None&'-.;=?HMSUVX{¸$first-class-patternsEVariable pattern: always succeeds, and binds the value to a variable.first-class-patternsgive bH always succeeds, ignoring the matched value and providing the value b) instead. Useful in conjunction with (")S for providing default values in cases that would otherwise not bind any values.first-class-patternsaWildcard pattern: always succeeds, binding no variables. (This is written as two underscores.)first-class-patterns Failure pattern: never succeeds. first-class-patterns:Predicate pattern. Succeeds if the given predicate yields P, fails otherwise.Can be used with (")) for some uses similar to pattern guards: ymatch a $ left (var /\ is even) ->> id <|> left __ ->> const 0 <|> right __ ->> const 1 Note that   is like @ but with Q instead of R ().!first-class-patterns:Constant pattern: test for equality to the given constant.cst x = is (==x)."first-class-patternsƒConjunctive (and) pattern: matches a value against two patterns, and succeeds only if both succeed, binding variables from both. (/\) = B (\a -> Just (a,a))#first-class-patterns}Disjunctive (or) pattern: matches a value against the first pattern, or against the second pattern if the first one fails.$first-class-patternsGView pattern: do some computation, then pattern match on the result.%first-class-patternsConvenient infix synonym for $.&first-class-patternsƒPartial view pattern: do some (possibly failing) computation, then pattern match on the result if the computation is successful.'first-class-patternsConvenient infix synonym for &.(first-class-patterns pfilter p matches every element of a S' data structure against the pattern p‰, discarding elements that do not match. From the matching elements, binds a list of values corresponding to each pattern variable.)first-class-patternspmap p matches every element of a T' data structure against the pattern pB. The entire match fails if any of the elements fail to match p). If all the elements match, binds a tK-structure full of bound values corresponding to each variable bound in p.*first-class-patterns pfoldr p f b matches every element of a S' data structure against the pattern p…, discarding elements that do not match. Folds over the bindings produced by the matching elements to produce a summary value.=The same functionality could be achieved by matching with  pfilter pi and then appropriately combining and folding the resulting lists of bound values. In particular, if p binds only one value we have Cmatch t (pfoldr p f b ->> id) === match t (pfilter p ->> foldr f b)However, when pÌ binds more than one value, it can be convenient to be able to process the bindings from each match together, rather than having to deal with them once they are separated out into separate lists.+first-class-patterns "Runs" a M, by matching it against a value and returning a result if it matches, or Nothing if the match fails.,first-class-patterns, satisfies the identity #match a c = fromJust (tryMatch a c).-first-class-patterns mmatch m p = m >>= . p>Useful for applicative-looking monadic pattern matching, as in kex7 :: IO () ex7 = mmatch getLine $ cst "" ->> return () <|> var ->> putStrLn . ("You said " ++).first-class-patterns  elim = flip ,DUseful for anonymous matching (or for building "eliminators", like U and V). For example: keither withLeft withRight = elim $ left var ->> withLeft <|> right var ->> withRight/first-class-patternsMatch True.0first-class-patternsMatch False.1first-class-patterns!A strict match on the unit value ().2first-class-patternsA synonym for 1.3first-class-patternsAConstruct a pattern match against a pair from a pair of patterns.4first-class-patternsA synonym for 3.5first-class-patternsMatch a 3-tuple.6first-class-patternsMatch a 4-tuple.7first-class-patternsMatch a 5-tuple.8first-class-patterns Match the W constructor of R.9first-class-patterns Match the X constructor of R.:first-class-patterns Match the Y constructor of Z.;first-class-patterns Match the [ constructor of Z.<first-class-patternsMatch the empty list.=first-class-patterns Match a cons.>first-class-patterns Match zero.?first-class-patterns…Match a natural number which is the successor of another natural (and match the predecessor with a nested pattern). Together, > and ? allow viewing Integral types as Peano numbers. Note that ? never matches negative numbers.* !"#$%&'()*+,-./0123456789:;<=>?@ABCDE*!"#$%&' ()*,+-./0123456789:;<=>?@ABCDE%5'5BSD3$Brent Yorgey <byorgey@cis.upenn.edu> experimentalnon-portable (see .cabal)None&';=?HMSUVX ;  !"#$%&'()*+,-./0123456789:;<=>?@ABCDE\      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZXY[\]^_`abcde\f\gdhdidjk3first-class-patterns-0.3.2.5-7zG3JzqAZ6x79JgmwRlvDoData.Pattern.BaseData.Pattern.Base.TypeListData.Pattern.Base.TupleData.Pattern.CommonData.Pattern.Base.Difference Data.PatternbaseGHC.Base<|>:++: Distribute distributeMapTupleFunzeroToneT<+>runTuple$fUncurriable:$fUncurriable[] $fTupable: $fTupable[] $fDistribute:$fDistribute[]Clause runClausePattern runPattern->>$fFunctorClause$fApplicativeClause $fMonadClause$fAlternativeClause$fMonadPlusClausevargive__pfailiscst/\\/view-->tryView-?>pfilterpmappfoldrtryMatchmatchmmatchelimtruefalseunittup0pairtup2tup3tup4tup5nothingjustleftrightnilconszerosucmk0mk1mk2mk3mk4mk5 DifferencezeroDplusDmkOneDevalDD runTupleTMonad MonadPlus Alternativeghc-prim GHC.TypesTrueBool GHC.MaybeMaybe Data.FoldableFoldableData.Traversable Traversable Data.Maybemaybe Data.EithereitherNothingJustLeftEitherRight