úÎ!0z/      (c) Samuel Schlesinger 2020-2024MITsgschlesinger@gmail.com experimental non-portableSafe%-./7=>?@AHSUVXfkq.Ð generic-match4The typeclass used to consume a product inside of a  type. generic-matchDThe type family that describes how to consume a product inside of a  type. generic-matchaThe class that is used to inductively define the pattern matching for a particular generic type. generic-match#The utility family which defines a :, after stripping the metadata from the top level of the   resentation.. generic-match The type family that strips the  off of a   resentation. generic-matchCThe type of a first class pattern match, having consumed the input. generic-match5A first class pattern matching function for anything , in the style of  and l, but with the first argument being the thing you are pattern matching on, as opposed to the last argument. either f g x == match x f g maybe r f x == match x r fBeyond working for  or Y, this function works on just about any type you give to it, as long as that type has a \ instance. For example, this code is from the tests which are not exported from this file: ÿdata Ploop = Clap Int Bool | Splop [Integer] Float | Flep [Int] [Float] [Bool] deriving Generic newtype X = X { unX :: Int } deriving Generic data Klop = Cloop Klop deriving Generic tests :: Bool tests = and [ match True False True , match False True False , match (Left (5 :: Int)) (== 5) undefined , match (Right ([1,2] :: [Int])) undefined ((== 2) . length) , match (Clap 0 True) (i b -> i == 0 && b) undefined undefined , match (X 1) (x -> x == 1) , match (let x = Cloop x in x) (_ -> True) ] ŽThere are other tests as well, at the type level, which I used to develop this library, and I think it makes sense to display those as well: ÿyfacts :: () facts = fold [ unitMatcher , boolMatcher , thingMatcher , pairMatcher , tripleMatcher , voidMatcher ] unitMatcher :: Matcher () r ~ (r -> r) => () unitMatcher = () boolMatcher :: Matcher Bool r ~ (r -> r -> r) => () boolMatcher = () data Thing = Thing Bool deriving Generic thingMatcher :: Matcher Thing r ~ ((Bool -> r) -> r) => () thingMatcher = () pairMatcher :: Matcher (Int, Bool) r ~ ((Int -> Bool -> r) -> r) => () pairMatcher = () tripleMatcher :: Matcher (Int, Int, Int) r ~ ((Int -> Int -> Int -> r) -> r) => () tripleMatcher = () voidMatcher :: Matcher Void r ~ r => () voidMatcher = () ðThese may look strange to the reader, but the way to read them is that the constraint to the left of the fat arrow must be true if I can instantiate one of the terms in a context without assuming it. As I instantiate all of them in that Ñ (possibly the only use of the '()' monoid that I can think of, all of these constraints must be true. This allowed me to develop this library by making instances that made each new constraint I added true.      !"#,generic-match-0.2.0.2-D96xssgtfC11SOaLIzQfkn Generic.MatchGHCGenericsbase GHC.GenericsGenericConsumeConsumerMatchMatcher' StripDataMatchermatch $fMatchkV1r $fConsumek:*: $fConsumekM1 $fConsumekU1 $fMatchk:+:r $fMatchkM1r$fGenericThing$fGenericPloop $fGenericX $fGenericKlopRepMetaData Data.Eithereither Data.Maybemaybe GHC.MaybeMaybeEither Data.Foldablefold