úΡž      Safe*+,69:;<=?DOQRT  Ensure that x, satisfies all of the constraints listed in cs. Convenience  for satisfying basic  needs for s and t.# trivially satisfied by every type.This can be used as the c parameter to   or @ in case you are not interested in observing the values inside f.Default   implementation for s and t.When defining  instances, you should leave c, m, f, and g< fully polymomrphic, as these are the most useful types of  Flayabless.If s and g are instances of , then ; gets a default implementation. For example, provided the Foo* datatype shown in the documentation for   had a  instance, then the following 1 instance would get a default implementation for :  instance ( m, c , c  ) =>  c m (Foo f) (Foo g) f g 7Notice that while this default definition works for an s having "nested  FlayablesC", GHC will prompt you for some additional constraints related to  in order for it to compile.   c m s t f g allows converting s to t by replacing ocurrences of f with g' by applicatively applying a function !(forall a. c a => f a -> m (g a)) to targeted occurences of f a inside s.A   must obey the   identity law (and   identity law as well, if the   fits the type expected by  ).When defining   values, you should leave c, m, f, and g< fully polymomrphic, as these are the most useful types of  s. When using a  , m will be required to be a ! in case the   targets one element, or an \ if it targets more than one. There will be no constraints on the rest of the arguments to  .We use  (c a) -> instead of c a =>… because the latter is often not enough to satisfy the type checker. With this approach, one must explicitely pattern match on the  (c a)# constructor in order to bring the c a0 instance to scope. Also, it's necessary that c$ is explicitly given a type at the Flay'Cs call site, as otherwise the type checker won't be able to infer c on its own.5to flay: tr. v., to strip off the skin or surface of. Mnemonic for  c m s t f g: CoMmon STandard FoG. Example 1: Removing uncertaininy(Consider the following types and values: data Foo f = Foo (f ) (f  ) deriving instance (" (f ), " (f  )) => " (Foo f)   flayFoo :: ( m, c , c  ) =>  9 c m (Foo f) (Foo g) f g flayFoo h (Foo a b) = Foo <$> h  a <*> h  b   foo1 :: Foo # foo1 = Foo ($ 1) %   foo2 :: Foo # foo2 = Foo ($ 2) ($ &) It is possible to remove the  uncertainty of the fields in Foo perhaps being empty (%) by converting Foo # to Foo '3. However, we can't just write a function of type Foo # -> Foo '= because we have the possiblity of some of the fields being % , like in foo1). Instead, we are looking for a function Foo # -> # (Foo ') which will result on $' only as long as all of the fields in Foo is $ , like in foo2. This is exactly what  enables us to do: fooMaybeToIdentity :: Foo # -> # (Foo ')) fooMaybeToIdentity (Foo a b) = Foo <$> ( ) a <*> ( ) b Example using this in GHCi: > fooMaybeToIdentity foo1 %  > fooMaybeToIdentity foo2 $ (Foo (' 2) (' &)) 4In fact, notice that we are not really working with $, %, nor '* directly, so we might as well just leave # and '1 polymorphic. All we need is that they both are s:  fooMToG :: ( m, 6 g) => Foo m -> m (Foo g) fooMToG (Foo a b) = Foo <$> ( ) a <*> ( ) b fooMToG behaves the same as fooMaybeToIdentity2, but more importantly, it is much more flexible: > fooMToG foo2 :: # (Foo []) $ (Foo [2] [&])  > fooMToG foo2 :: # (Foo (* +)) $ (Foo (, 2) (, &))  Y, among other things, is intended to generalize this pattern so that whatever choice of Foo, # or ' you make, you can use " this way. The easiest way to use   is through  c, which is sufficient unless we need to enforce some constrain in the target elements wrapped in m+ inside foo (we don't need this now). With  , we could have defined fooMToG this way:  fooMToG :: ( m, $ g) => Foo m -> m (Foo g) fooMToG =   flayFoo (( )) =Some important things to notice here are that we are reusing flayFoo's knowledge of Foo'*s structure, and that the construction of g using ) applies to any value wrapped in m ( and  * in our case). Compare this last fact to -I, where the types of the targets must be the same, and known beforehand.Also, notice that we inlined flayFoor for convenience in this example, but we could as well have taken it as an argument, illustrating even more how  7 decouples the shape and targets from their processing:  flayMToG :: ( m,  g) =>   % m s t m g -> s -> m s flayMToG fl =   fl (( )) This is the escence of  5: We can work operate on the contents of a datatype s targeted by a given   without knowing anything about s, nor about the  forall x. f x targets of the  :. And we do this using an principled approach relying on  and !. We can use a  L to repurpose a datatype while maintaining its "shape". For example, given Foo: Foo '( represents the presence of two values  and ., Foo #& represents their potential absence, Foo []+ represents the potential for zero or more s and .s, Foo (/ x). represent the presence of two values of type x, and Foo 0 represents two 0, actions necessary to obtain values of type  and . . We can use flayFooM to convert between these representations. In all these cases, the shape of Foox is preserved, meaning we can continue to pattern match or project on it. Notice that even though in this example the f argument to Foo happens to always be a ! , this is not necessary at all.Example 2: Standalone mIn the previous example, flayFoo took the type Flay  m (Foo m) (Foo g) m g when it was used in flayMToG . That is, m and f were unified by our use of (j. However, keeping these different opens interesting possibilities. For example, let's try and convert a Foo # to a Foo (* +), prompting the user for the 1 side of that *0 whenever the original target value is missing.  prompt :: 0 + prompt = do 2$ "Missing value! Error message? " 3  fooMaybeToEitherIO :: Foo # -> 0 (Foo (* +)) fooMaybeToEitherIO =   flayFoo $ \case % -> ( 1 prompt $ x -> ) (, x) Using this in GHCi: 8> fooMaybeToEitherIO foo1 Missing value! Error message?  Nooooo!!!!! Foo (, 1) (1 "Nooooo!!!!!")  > fooMaybeToEitherIO foo2 Foo (, 2) (, &) Example 3: ContextsHExtending the previous example we "replaced" the missing values with a +x, but wouldn't it be nice if we could somehow prompt a replacement value of the original type instead? That's what the c argument to   is for. Let's replace prompt- so that it can construct a type other than +:  prompt :: 4 x => 0 x prompt = do 2" "Missing value! Replacement? " 5  Notice how prompt now has a 4 x7 constraint. In order to be able to use the result of prompt, as a replacement for our missing values in Foo #, we will have to mention 4 as the c argument to  , which implies that 4F will have to be a constraint satisfied by all of the targets of our   (as seen in the constraints in flayFoo). We can't use   anymore, we need to use flayFoo directly: fooMaybeToIdentityIO :: Foo # -> 0 (Foo '0) fooMaybeToIdentityIO = flayFoo h where h ::  (4 a) -> # a -> 0 (' a) h  = \case % -> ( ) prompt $ a -> ) () a) ;Notice how we had to give an explicit type to our function h#: This is because can't infer our 4 aC constraint. You will always need to explicitly type the received  unless the c argument to  A has been explicitely by other means (like in the definition of  *, where we don't have to explicitly type  because c ~ * according to the top level signature of  ).Example using this in GHCi: 8> fooMaybeToIdentityIO foo1 Missing value! Replacement? & Foo (' 1) (' &)  !> fooMaybeToIdentityIO foo2 Foo (' 2) (' &) (Of course, as in our previous examples, '% here could have generalized to any . We just fixed it to ' as an example.3You can mention as many constraints as you need in c as long as c has kind k ->  (where k is the kind of f—'s argument). You can always group together many constraints as a single new one in order to achieve this. For example, if you want to require both " and 4= on your target types, then you can introduce the following  ShowAndRead class, and use that as your c. class (" a, 4 a) => ShowAndRead a instance (" a, 4 a) => ShowAndRead a (This is such a common scenario that the Flay module exports , a  you can use to apply many 0s at once. For example, instead of introducing  ShowAndRead, we could use  '[", 4] as our c argument to  ', and the net result would be the same. Example 4: See the documentation for . To sum up: for any given  , we can collect all of the Flay's targets into a 6t, without knowing anything about the targets themselves beyond the fact that they satisfy a particular constraint. Inner identity law: (\fl -> 7 .   fl )) = 8 Outer identity law: (\fl -> 9 .   fl )) = 8  You can use   if you don't care about the c argument to  6. This implies that you won't be able to observe the a in  forall a. f a, all you can do with such a is pass it around.   fl h = fl (\( ::  ( a)) (fa :: f a) -> h fa) Like  , but works on a  instead of taking an explicit  .   =    Collect all of the f a of the given   into a 6 b.Example usage, given Foo and flayFoo* examples given in the documentation for  : >  flayFoo (\( ::  (" a)) (' (a :: a)) -> [: a]) (Foo () 4) () &)) ["4","True"] Like , but works on a  instead of an explicit  .Isomorphic to c a => f a -> m (g a).;     ; <      !"#!$%&'!$(!)*!$+!$,!$-.!/0!$1!$2!34!$5!36!789!:;<!3=!>?!>@!AB!>C!$D!/E!$F!$G!)HIJflay-0.1-JilFyawlEwq7AanoTHfr4Flay(constraints-0.9.1-ACSy42uSnNL1E7qGEIP1kyData.ConstraintDictAllGFlay'gflay'GFlayTrivialFlayableflayinneroutertrivial'trivialgflaycollect'collect $fAllkcsx$fGFlay'TYPEkcm:+::+:fg$fGFlay'TYPEkcm:*::*:fg$fGFlay'TYPEkcmM1M1fg$fGFlay'TYPEkcmK1K1fg$fGFlay'TYPETYPEcmK1K1fg$fGFlay'TYPEkcmRec1Rec1fg$fGFlay'TYPEkcmV1V1fg$fGFlaykcmstfg $fTrivialka$fFlayablecmfgfgghc-prim GHC.Types Constraintbase GHC.GenericsGenericGHC.Base ApplicativeIntBoolFunctorGHC.ShowShowMaybeJustNothingTrueData.Functor.IdentityIdentityfmappure Data.EitherEitherStringRightData.TraversabletraverseCharData.Functor.ConstConstIOLeft System.IOputStrgetLineGHC.ReadReadreadLnMonoid runIdentityidjoinshowAll'