<!doctype html>
<html>
 <head> 
  <meta charset="UTF-8"> 
 </head>
 <body>
  <div>
   <br>
  </div>
  <blockquote type="cite">
   <div>
    On 10/08/2021 5:33 AM Anthony Clayden <anthony.d.clayden@gmail.com> wrote:
   </div>
   <div>
    <br>
   </div>
   <div>
    <br>
   </div>
   <div dir="ltr">
    <span style="background-color: #ffffff; font-family: arial, sans-serif;"><br></span>
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;">> <span style="color: #000000; white-space: pre-wrap;">I was surprised to find the below code doesn't typecheck even with -XLiberalTypeSynonyms. Am I missing something or is this really not possible?</span></span>
    </div>
    <pre style="white-space: pre-wrap; color: #000000;"><br></pre><span style="background-color: #ffffff; font-family: arial, sans-serif;">Reading the error message would help:</span>
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;"><br></span>
    </div>
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;">* The type synonym `Foo' should have 2 arguments, but has been given 1</span>
    </div>
   </div>
  </blockquote>
  <div>
   <br>
  </div>
  <div class="default-style" style="">
   I'm not sure what in my question made it seem like I hadn't read this error message. With my code as written I can't apply both arguments, and I'm trying to solve the problem in front of me given that fact.
   <br>
  </div>
  <div class="default-style">
   <br>
  </div>
  <blockquote type="cite">
   <div dir="ltr">
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;"></span>
    </div>
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;">-XLiberalTypeSynonyms relaxes the 'saturated application' rule a little <a href="https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/liberal_type_synonyms.html?highlight=type%20synonym#liberalised-type-synonyms">https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/liberal_type_synonyms.html?highlight=type%20synonym#liberalised-type-synonyms</a></span>
     <br>
    </div>
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;"><br></span>
    </div>
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;"><span style="color: #404040;">"You can apply a </span><span style="box-sizing: border-box; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-origin: initial; background-clip: initial; display: inline-block; padding: 0px 6px; color: #404040;" class="gmail-highlighted">type</span><span style="color: #404040;"> </span><span style="box-sizing: border-box; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-origin: initial; background-clip: initial; display: inline-block; padding: 0px 6px; color: #404040;" class="gmail-highlighted">synonym</span><span style="color: #404040;"> to a partially applied type synonym:"</span><br></span>
    </div>
    <div>
     <span style="color: #404040; background-color: #ffffff;"><span style="font-family: arial, sans-serif;"><br></span></span>
    </div>
    <div>
     <span style="color: #404040; background-color: #ffffff;"><span style="font-family: arial, sans-serif;">But that isn't what you're doing. The docs say that still</span></span>
    </div>
    <div>
     <span style="color: #404040; background-color: #ffffff;"><span style="font-family: arial, sans-serif;"><br></span></span>
    </div>
    <div>
     <span style="background-color: #ffffff; font-family: arial, sans-serif;"><span style="color: #404040;">" ... </span><span style="color: #404040;">malformedness ... * </span><span style="color: #404040;">Partially-applied </span><span style="color: #404040; box-sizing: border-box; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-origin: initial; background-clip: initial; display: inline-block; padding: 0px 6px;" class="gmail-highlighted">type</span><span style="color: #404040;"> </span><span style="color: #404040; box-sizing: border-box; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-origin: initial; background-clip: initial; display: inline-block; padding: 0px 6px;" class="gmail-highlighted">synonym</span><span style="color: #404040;">."</span></span>
    </div>
    <div>
     <span style="color: #404040; background-color: #ffffff;"><span style="font-family: arial, sans-serif;"><br></span></span>
    </div>
    <div>
     <span style="background-color: #fcfcfc; color: #404040;"><span style="font-family: arial, sans-serif;">Type Synonyms are not functions. Think of them as 'macro' expansions.</span></span>
    </div>
    <div>
     <span style="background-color: #fcfcfc; color: #404040;"><span style="font-family: arial, sans-serif;"></span></span>
    </div>
   </div>
  </blockquote>
  <div>
   <br>
  </div>
  <div class="default-style">
   Interestingly I get an almost identical error when defining Foo as a type family, which seems a lot more akin to a function.
   <br>
  </div>
  <div class="default-style">
   <br>
  </div>
  <blockquote type="cite">
   <div dir="ltr">
    <div>
     <span style="background-color: #fcfcfc; color: #404040;"><span style="font-family: arial, sans-serif;">Possibly your `Bar` could be a type synonym, taking `(Foo Maybe)` as an argument in the `instance Eq`. </span></span>
    </div>
   </div>
  </blockquote>
  <div>
   <div>
    <br>
   </div>
   <div class="default-style">
    Thank you for this concrete suggestion. I'd actually tried variations on this before asking on the list, and I've tried a few more just now, but I'm very willing to believe I'm simply not looking in the right place. Certainly a simple `type Bar' x = Bar x` isn't changing anything.
    <br>
   </div>
  </div>
  <div class="default-style">
   <br>
  </div>
  <blockquote type="cite">
   <div dir="ltr">
    <div>
     <span style="background-color: #fcfcfc; color: #404040;"><span style="font-family: arial, sans-serif;">What type is it exactly that you want to derive an instance for?</span></span>
    </div>
    <div>
     <span style="background-color: #fcfcfc; color: #404040;"><span style="font-family: arial, sans-serif;"></span></span>
    </div>
   </div>
  </blockquote>
  <div>
   <br>
  </div>
  <div class="default-style">
   Other than excluding unnecessary details, I've provided code that's pretty similar to the real code I'm working on. The biggest difference is that `Bar` is actually defined more like:
   <br>
   <br>    data Bar (m :: * -> *) = Bar { a :: m Int, b :: m Bool, c :: m Double }
   <br> 
   <br>
  </div>
  <div class="default-style">
   <br>
  </div>
  <div class="default-style">
   So it really does need to take a `* -> *` type
   <br>
  </div>
  <div class="default-style">
   <br>
  </div>
  <div class="default-style">
   Thanks,
   <br>
  </div>
  <div class="default-style">
   Tom
   <br>
  </div>
  <blockquote type="cite">
   _______________________________________________Haskell-Cafe mailing list
   <br>To (un)subscribe, modify options or view archives go to:
   <br>http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
   <br>Only members subscribed via the mailman list are allowed to post.
  </blockquote>
 </body>
</html>