haskell - ScopeTypeVariables is Failing To Help Inference -


I have a utility function to forward calls to type class method through a type of type. I problem That I have to pass the barrier clearly using the proxy. I would just like to use ScopedTypeVariables.

Here is the code

  {- # LANGUAGE type operator} - # {- # LANGUAGE Flexible difference # -} {- # language negligence qualifications # -} {- # LANGUAGE LambdaCase # -} {- # LANGUAGE Rankings # -} {- # LANGUAGE Obligations # -} {- # LANGUAGE scrapptive variables # -} {- # LANGUAGE DEVOVER GENERIC # -} {- # LANGUAGE analogy # -} {- # LANGUAGE MultiParamTypeClasses # -} Mitsuba.Generic module where imported GHC.Generics import data. Proxy Class GFold fcb Where genericFold :: PC - & gt; (Foral ECE => E -> B) - & gt; F.A - & gt; B example GFold a c d => Gfold (M1xYA) CD, where genericfold pf (m1x) = genericfold pf x instance (gold acd, g fold bcd) = & gt; Gifold (A: +: B) CD where generic fold pf = \ case L1 x - & gt; GenericFold (Proxy :: Proxy C) FX R1X - & gt; GenericFold (Proxy :: Proxy C) FX Example CA = & gt; Gifold (K1I) C D Genericfold PF (K1x) = FX Gfold :: (Generic A, G Fold (Rep. A) CD)> & gt; Pc - & gt; (Foral ECE => E - & gt; D) - & gt; A - & gt; D gfold pH x = genericfold pH $ x data from foo = I int. | D double | B-Bool deriving (general) test :: string test = gfold (proxy :: proxy show) Show $ I 1  

So like the exam I would like to do this however, I would like to 'gfold' function I would like to

  gfold :: forall a c d (generic a, g fold (rape a) cd) = & gt; (Foral ECE => E - & gt; D) - & gt; A - & gt; D gfold hx = genericFold (Proxy :: Proxy C) H $ to X  

which compiles, but then the test returns the following error.

  src /Generic.hs39:8: In expression: gfold Show expression: gfold shows $ i1 in an equation causing `` gfold '' (c0 Bool, c0 double, c0 int) could not be removed 'test': test = gfold show $ i 1 src / generic.hs: 39: 14: References referred to by reference in a manner referred to as 'show' Could not show the show (e-show) used. : (C E) = & gt; E - & gt; String on Src / mitsuba / generic.hs: 39: 8-17 Potential improvements: Add context (in context to the required type of reference): (c0i) = & gt; E - & gt; In the first argument of string 'gfold', i.e. `show 'expression in: gfold show expression: gfold show $ i 1  

Anyway anyway I can write a version of gfold that I Want to

I do not think you can unify c Show in this case because show is not the only possible obstacle that matches c to (forall ee => e- & Gt; d) . It may also be some other type of class, which means show , for example:

  show class a => MyShow is one where myShow :: a - & gt; String myShow a = "foo:" ++ An example shows the MyShow int example MyShow double example MyShow Bool  

and now

  test = gfold (Proxy :: ProxyMeyShow) Show $ I1  

Also type-check


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -