Clear and concise answer.<br><br>Thank you.<br><br><div class="gmail_quote">On Thu, Apr 15, 2010 at 21:24, Daniel Fischer <span dir="ltr"><<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Am Donnerstag 15 April 2010 19:19:15 schrieb Romulus:<br>
> Hello everyone,<br>
<div class="im">><br>
<br>
><br>
> I'm stuck with the definition of the helper for LAnd'. I expect :<br>
><br>
> land' :: ((LAnd' p) :<: (f p)) => Mu (f p) -> Mu (f p) -> Mu (f p)<br>
> land' = \x y -> inject (LAnd' x y)<br>
><br>
> ... but ghci 6.10.4 does not really like this definition...<br>
><br>
> Could not deduce (LAnd' p :<: f p1)<br>
> from the context (LAnd' p1 :<: f p1)<br>
> arising from a use of `inject' at PropSample.hs:128:16-33<br>
> Possible fix:<br>
> add (LAnd' p :<: f p1) to the context of<br>
> the type signature for `land''<br>
> or add an instance declaration for (LAnd' p :<: f p1)<br>
> In the expression: inject (LAnd' x y)<br>
> In the expression: \ x y -> inject (LAnd' x y)<br>
> In the definition of `land'': land' = \ x y -> inject (LAnd' x y)<br>
> Failed, modules loaded: none.<br>
><br>
><br>
><br>
> Does anybody have a clue for this problem ?<br>
> I don't really understand where is the trouble actually.<br>
<br>
</div>The expression (Land' x y) can have the type (Land' q (Mu (f p))) for all<br>
q. But there's only an instance for the p used in Mu (f p) provided, so<br>
<div class="im"><br>
Could not deduce (LAnd' p :<: f p1)<br>
from the context (LAnd' p1 :<: f p1)<br>
<br>
</div>The solution is to tell the compiler that this expression should have the<br>
type LAnd' p (Mu (f p)) for the f and p from the type signature, add<br>
<br>
{-# LANGUAGE ScopedTypeVariables #-}<br>
<br>
and modify land' to<br>
<br>
land' :: forall f p. ((LAnd' p) :<: (f p)) => Mu (f p) -> Mu (f p) -> Mu<br>
(f p)<br>
land' = \x y -> inject (LAnd' x y :: LAnd' p (Mu (f p)))<br>
<br>
to be greeted by<br>
<br>
<br>
[1 of 1] Compiling Prop ( PropSample.hs, interpreted )<br>
<br>
PropSample.hs:31:16:<br>
Warning: Declaration of `In' uses deprecated syntax<br>
Instead, use the form<br>
In :: {out :: f (Mu f)} -> Mu f<br>
Ok, modules loaded: Prop.<br>
*Prop><br>
<br>
by 6.12.1 and<br>
<br>
$ ghci-6.10.3 PropSample<br>
GHCi, version 6.10.3: <a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a> :? for help<br>
Loading package ghc-prim ... linking ... done.<br>
Loading package integer ... linking ... done.<br>
Loading package base ... linking ... done.<br>
[1 of 1] Compiling Prop ( PropSample.hs, interpreted )<br>
Ok, modules loaded: Prop.<br>
*Prop><br>
<br>
from the older GHC.<br>
<div><div></div><div class="h5"><br>
><br>
> Cheers,<br>
><br>
> PS: haskellers rulez ;)<br>
<br>
+1<br>
<br>
><br>
><br>
> [1]<br>
> Swierstra, W.<br>
> Data types à la carte<br>
> J. Funct. Program.<br>
> Cambridge University Press, 2008, 18, 423-436<br>
><br>
> [2]<br>
> Knowles, K.<br>
> First-Order Logic à la Carte<br>
> The Monad.Reader, 2008, issue 11<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Romuald THION<br>Docteur level 1.0 - Great master access control, +3 against half-dead<br>"la vie, c'est comme un jeu mal foutu dont on ne connait pas les règles et où il n'y a pas de sauvegardes"<br>
<br>