Ah, maybe Dan could tell us if it works only with GHC 7.<br><br>Dmitry, I had your problem many times. The last time was when I saw you could define the ContT monad in terms of Cont (the opposite is done in the mtl).<br>It leads to a simpler code, but you are stucked when trying to define ContT as an instance of MonadTrans:<br>

<br>data Cont r a = ...<br>-- [instances of Monad Cont, blah blah blah]<br><br>type ContT r m a = Cont r (m a)<br><br>instance MonadTrans (ContT r) where  -- <b>This doesn&#39;t compile</b>, even if it is logical<br>  lift = ...<br>

<br>For short, type synonyms work for mere aliases, but not for full-fledged type-level non-inductive functions.<br>And sometimes we intuitively want to use them as such.<br><br><div class="gmail_quote">2011/12/7 Dmitry Kulagin <span dir="ltr">&lt;<a href="mailto:dmitry.kulagin@gmail.com">dmitry.kulagin@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">&gt; Dmitry, does your code work with LiberalTypeSynonyms extention activated?<br>
</div>No, the same error:<br>
Type synonym `StateA&#39; should have 1 argument, but has been given 0<br>
<br>
But I have GHC 6.12.3<br>
<br>
Dmitry<br>
2011/12/7 Yves Parès &lt;<a href="mailto:limestrael@gmail.com">limestrael@gmail.com</a>&gt;:<br>
<div class="HOEnZb"><div class="h5">&gt; This is impossible:<br>
&gt; in the definition of &#39;StateT s m a&#39;, m must be a monad and then have the *<br>
&gt; -&gt; * kind.<br>
&gt; So you cannot pass (StateA a), because it has simply the * kind.<br>
&gt;<br>
&gt; Dmitry, does your code work with LiberalTypeSynonyms extention activated?<br>
&gt;<br>
&gt;<br>
&gt; 2011/12/7 Øystein Kolsrud &lt;<a href="mailto:kolsrud@gmail.com">kolsrud@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; You should be able to write something like this:<br>
&gt;&gt;<br>
&gt;&gt; type StateB a b = StateT SomeOtherState (StateA a) b<br>
&gt;&gt;<br>
&gt;&gt; Best regards, Øystein Kolsrud<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Dec 7, 2011 at 11:48 AM, Dmitry Kulagin &lt;<a href="mailto:dmitry.kulagin@gmail.com">dmitry.kulagin@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi Dan,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I am still pretty new in Haskell, but this problem annoys me already.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; If I define certain monad as a type synonym:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    type StateA a = StateT SomeState SomeMonad a<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Then I can&#39;t declare new monad based on the synonym:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    type StateB a = StateT SomeOtherState StateA a<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The only way I know to overcome is to declare StateA without `a&#39;:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;    type StateA = StateT SomeState SomeMonad<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; But it is not always possible with existing code base.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I am sorry, if this is offtopic, but it seemed to me that the problem<br>
&gt;&gt;&gt; is realted to partially applied type synomyms you described.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks!<br>
&gt;&gt;&gt; Dmitry<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Tue, Dec 6, 2011 at 10:59 PM, Dan Doel &lt;<a href="mailto:dan.doel@gmail.com">dan.doel@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt; &gt; Greetings,<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; In the process of working on a Haskell-alike language recently, Ed<br>
&gt;&gt;&gt; &gt; Kmett and I realized that we had (without really thinking about it)<br>
&gt;&gt;&gt; &gt; implemented type synonyms that are a bit more liberal than GHC&#39;s. With<br>
&gt;&gt;&gt; &gt; LiberalTypeSynonyms enabled, GHC allows:<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;    type Foo a b = b -&gt; a<br>
&gt;&gt;&gt; &gt;    type Bar f = f String Int<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;    baz :: Bar Foo<br>
&gt;&gt;&gt; &gt;    baz = show<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; because Bar expands to saturate Foo. However, we had also implemented<br>
&gt;&gt;&gt; &gt; the following, which fails in GHC:<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;    type Foo a b = b -&gt; a<br>
&gt;&gt;&gt; &gt;    type Bar f = f (Foo Int) (Foo Int)<br>
&gt;&gt;&gt; &gt;    type Baz f g = f Int -&gt; g Int<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;    quux :: Bar Baz<br>
&gt;&gt;&gt; &gt;    quux = id<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; That is: type synonyms are allowed to be partially applied within<br>
&gt;&gt;&gt; &gt; other type synonyms, as long as similar transitive saturation<br>
&gt;&gt;&gt; &gt; guarantees are met during their use.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; I don&#39;t know how useful it is, but I was curious if anyone can see<br>
&gt;&gt;&gt; &gt; anything wrong with allowing this (it seems okay to me after a little<br>
&gt;&gt;&gt; &gt; thought), and thought I&#39;d float the idea out to the GHC developers, in<br>
&gt;&gt;&gt; &gt; case they&#39;re interested in picking it up.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; -- Dan<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt;&gt; &gt; Haskell-Cafe mailing list<br>
&gt;&gt;&gt; &gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt;&gt;&gt; &gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; Haskell-Cafe mailing list<br>
&gt;&gt;&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt;&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Mvh Øystein Kolsrud<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Haskell-Cafe mailing list<br>
&gt;&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>