From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=AWL,HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id D0A98BBC4 for ; Wed, 4 Mar 2009 17:35:39 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiACAIQ8rkmLEwEygGdsb2JhbACCIy6SMQEBCwsKBRMFsxKQJASECA X-IronPort-AV: E=Sophos;i="4.38,301,1233529200"; d="scan'208,217";a="22046461" Received: from apollo.mpi-sb.mpg.de ([139.19.1.50]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 04 Mar 2009 17:35:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=Message-Id:From:To:In-Reply-To: Content-Type:Subject:Mime-Version:Date:References; bh=yZ26IUj/CM B0GqreNVL5vTPiBaxzRwAx8xAAQzNvQpY=; b=Hx7UkGYT7LtnaYMypm0513sHKK hnu0+W96txztiyR2EJRuHPLeGtHtMAdQQH7mEa8ahcOne5kPHU9MU0tt9/E811MI kAbWCaLe0TZ73jp4wUFFq/LlEWyH3WOr906dHVCrr+Dpvqm+WQMdHsCFhE20C5sF zujGrdjxdlLyhuSf8= Received: from newmaniac.mpi-sb.mpg.de ([139.19.1.26]:52211) by apollo.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1Leu4C-0000xn-2a; Wed, 04 Mar 2009 17:35:38 +0100 Received: from srbk-5d801ea2.pool.einsundeins.de ([93.128.30.162]:60426 helo=[192.168.178.20]) by newmaniac.mpi-sb.mpg.de with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.63) (envelope-from ) id 1Leu4B-0007ra-H8; Wed, 04 Mar 2009 17:35:31 +0100 Message-Id: <55744D9F-3DF2-420E-B206-B27AC403DD35@mpi-sws.mpg.de> From: Andreas Rossberg To: caml-list@yquem.inria.fr In-Reply-To: Content-Type: multipart/alternative; boundary=Apple-Mail-2-179292964 Subject: Re: [Caml-list] stl? Mime-Version: 1.0 (Apple Message framework v930.3) Date: Wed, 4 Mar 2009 17:35:30 +0100 References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> <200903040159.48574.jon@ffconsultancy.com> <200903040920.01990.peng.zang@gmail.com> X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; rossberg:01 rossberg:01 stl:01 haskell:01 haskell:01 mpg:98 wrote:01 wrote:01 andreas:01 andreas:01 caml-list:01 ghc:01 ghc:01 000000:97 string:02 --Apple-Mail-2-179292964 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On Mar 4, 2009, at 17.14 h, Brian Hurt wrote: > > So then you start throwing out the standard instances, among others, > you do one for string: > instance Sexpable String where > toSexp s = Atom s > fromSexp (Atom s) = Just s > fromSexp _ = Nothing > > and, a little while later, one for generic lists: > instance Sexpable a => Sexpable [ a ] where > toSexp xs = List $ map toSexp xs > fromSexp (List xs) = mapM fromSexp xs > fromSexp _ = Nothing > > Opps! Now you have conflicting instances for type String- one the > explicit implementation, and one via the generic list. To be fair, your String instance is using a GHC extension. It is not legal in plain Haskell. IMO, in this particular example, the problem is caused not so much by limitations of type classes as such (which exist, of course), but by the somewhat questionable idea of defining a fundamental type like String as a list of chars, transparently. - Andreas --Apple-Mail-2-179292964 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable
On Mar 4, 2009, at = 17.14 h, Brian Hurt wrote:

So then you = start throwing out the standard instances, among others, you do one for = string:
= instance Sexpable String where
toSexp s =3D Atom s
fromSexp = (Atom s) =3D Just s
fromSexp _ =3D = Nothing

and, a little while later, one for generic = lists:
= instance Sexpable a =3D> Sexpable [ a ] where
toSexp xs = =3D List $ map toSexp xs
fromSexp (List xs) =3D mapM = fromSexp xs
= = fromSexp _ =3D Nothing

Opps!  Now you have = conflicting instances for type String- one the explicit implementation, = and one via the generic list.

To = be fair, your String instance is using a GHC extension. It is not legal = in plain Haskell.

IMO, in this particular = example, the problem is caused not so much by limitations of type = classes as such (which exist, of course), but by the somewhat = questionable idea of defining a fundamental type like String as a list = of chars, transparently.

- = Andreas

= --Apple-Mail-2-179292964--