Robert van Herk wrote:

Sorry, this is the compiler error I get:

No instances for (KeyHasValue MyKeyVal k' v',
                     Datasource.Tools.FakePrelude.TypeEq Float k' z,
                     Datasource' z [MyKeyVal] [MyKeyVal] Float Int)
When I am trying to do

 do { createJoinedDS' x x;
         (joined,(v::Maybe Int)) <- _dsread joined (2.0::Float);
      }

Robert

------------------------------------------------------------------------

Subject:
Re: Allowing duplicate instances in GHC 6.4
From:
Robert van Herk <[EMAIL PROTECTED]>
Date:
Thu, 31 Mar 2005 16:49:07 +0200
To:
[email protected]

To:
[email protected]

Return-Path:
<[EMAIL PROTECTED]>
X-Original-To:
[EMAIL PROTECTED]
Delivered-To:
[EMAIL PROTECTED]
Received:
from mail.students.cs.uu.nl (localhost.localdomain [127.0.0.1]) by mail.students.cs.uu.nl (Postfix) with ESMTP id 85339225D8C for <[EMAIL PROTECTED]>; Thu, 31 Mar 2005 16:54:12 +0200 (CEST)
Received:
from mail.cs.uu.nl (dusk.cs.uu.nl [131.211.80.10]) by mail.students.cs.uu.nl (Postfix) with ESMTP id 68C95225D84 for <[EMAIL PROTECTED]>; Thu, 31 Mar 2005 16:54:12 +0200 (CEST)
Received:
by mail.cs.uu.nl (Postfix) id EF0D9A35E2; Thu, 31 Mar 2005 16:54:11 +0200 (CEST)
Delivered-To:
[EMAIL PROTECTED]
Received:
from mail.cs.uu.nl (localhost.localdomain [127.0.0.1]) by mail.cs.uu.nl (Postfix) with ESMTP id D9C06A35F7; Thu, 31 Mar 2005 16:54:11 +0200 (CEST)
Received:
from www.haskell.org (bugs.haskell.org [128.36.229.215]) by mail.cs.uu.nl (Postfix) with ESMTP id 99FA2A35E2; Thu, 31 Mar 2005 16:54:11 +0200 (CEST)
Received:
from haskell.cs.yale.edu (localhost.localdomain [127.0.0.1]) by www.haskell.org (Postfix) with ESMTP id 666A436825E; Thu, 31 Mar 2005 09:36:48 -0500 (EST)
X-Original-To:
[email protected]
Delivered-To:
[email protected]
Received:
from mail.cs.uu.nl (dusk.cs.uu.nl [131.211.80.10]) by www.haskell.org (Postfix) with ESMTP id 3A87D368106 for <[email protected]>; Thu, 31 Mar 2005 09:36:45 -0500 (EST)
Received:
from mail.cs.uu.nl (localhost.localdomain [127.0.0.1]) by mail.cs.uu.nl (Postfix) with ESMTP id 16C67A35F7; Thu, 31 Mar 2005 16:54:05 +0200 (CEST)
Received:
from [131.211.84.110] (mckroket.labs.cs.uu.nl [131.211.84.110]) by mail.cs.uu.nl (Postfix) with ESMTP id 0635AA35E2; Thu, 31 Mar 2005 16:54:05 +0200 (CEST)
Message-ID:
<[EMAIL PROTECTED]>
User-Agent:
Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language:
en-us, en
MIME-Version:
1.0
References:
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
In-Reply-To:
<[EMAIL PROTECTED]>
Content-Type:
text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding:
7bit
X-AV-Checked:
ClamAV using ClamSMTP at cs.uu.nl
X-BeenThere:
[email protected]
X-Mailman-Version:
2.1.5
Precedence:
list
List-Id:
The Glasgow Haskell Users Mailing List <glasgow-haskell-users.haskell.org>
List-Unsubscribe:
<http://www.haskell.org/mailman/listinfo/glasgow-haskell-users>, <mailto:[EMAIL PROTECTED]>
List-Archive:
<http://www.haskell.org//pipermail/glasgow-haskell-users>
List-Post:
<mailto:[email protected]>
List-Help:
<mailto:[EMAIL PROTECTED]>
List-Subscribe:
<http://www.haskell.org/mailman/listinfo/glasgow-haskell-users>, <mailto:[EMAIL PROTECTED]>
Sender:
[EMAIL PROTECTED]
Errors-To:
[EMAIL PROTECTED]
X-AV-Checked:
ClamAV using ClamSMTP at cs.uu.nl
X-AV-Checked:
ClamAV using ClamSMTP at students.cs.uu.nl
X-Spam-Checker-Version:
SpamAssassin 3.0.2-hvl (2004-11-16) on dawn.students.cs.uu.nl
X-Spam-Status:
No, score=-0.7 required=7.0 tests=AWL autolearn=ham version=3.0.2-hvl



Hi Keean,

First of all, thank you for your answers. I have tried your solution using TypeEq.

instance (Datasource l k' v', TypeEq k k' z, Datasource' z l r k v) =>
Datasource (JoinedDS l r) k v where
_dsread (JoinedDS refl refr) k = do { l <- readIORef refl;
r <- readIORef refr; (z,l,r,v) <- _dsread' (l,r) k;
writeIORef refl l;
writeIORef refr r;
return (JoinedDS refl refr, v);
}


class Datasource' z l r k v | l r k -> v where

class Datasource' z l r k v | z l r k -> v where

 _dsread'  :: (l,r) -> k -> IO (z,l,r,Maybe v)
 _dswrite' :: (l,r) -> k -> v -> IO (z,l,r)
instance Datasource l k v => Datasource' HTrue  l r k v where
 _dsread' (l,r) k = do { (l,v) <- _dsread l k;
                         return (hTrue, l, r, v);
                       }
instance Datasource r k v => Datasource' HFalse l r k v where
 _dsread' (l,r) k = do { (r,v) <- _dsread r k;
                         return (hFalse, l, r, v);
                       }

This compiles.

I cannot, however, include type z in the fundep of Datasource', since this conflicts with Datasource ds k v | ds k -> v. Furthermore, I do not understand how the key and value types of my right datasource (r k v) is bound to the instance of Datasource (JoinedDS l r) k v, since in the premisse (Datasource l k' v', TypeEq k k' z, Datasource' z l r k v), nothing is said about Datasource r k'' v''. However, I could be wrong in this, since Datasource r k v is in the premisse of instance Datasource r k v => Datsource' HFalse l r k v.

However, my problem is, that when I use this code:

do {joined <- createJoinedDS' x y;
     (joined,(v::Maybe Int)) <- _dsread joined (2.0::Float);
    }

{- | Easy constructor -}
createJoinedDS :: (IORef left) -> (IORef right) -> JoinedDS left right
createJoinedDS left right = JoinedDS left right
createJoinedDS' :: left -> right -> IO (JoinedDS left right)
createJoinedDS' l r = do { left <- newIORef l;
                          right <- newIORef r;
                          return (createJoinedDS left right);
                        }

the compiler will complain:

 Could not deduce (Datasource' z1 l r k v)
     from the context (Datasource (JoinedDS l r) k v,
                       Datasource l k' v',
                       TypeEq k k' z,
                       Datasource' z l r k v)
     arising from use of `_dsread''

It seems to be the case that it cannot decide on the type of z.

See change above!

Also note type of fundep for Datasource should now be:

class Datasource s k v | s -> k v where ...

   Keean.

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to