Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Help in reading XML into a data type with HXT (Alexis Praga)
2. Re: Help in reading XML into a data type with HXT
(Michael Orlitzky)
3. Re: Help in reading XML into a data type with HXT (Alexis Praga)
4. Re: Show and showList (Animesh Saxena)
5. Re: ghc failed to compile trifecta while installing idris
(Robert Dodier)
----------------------------------------------------------------------
Message: 1
Date: Sat, 24 Jan 2015 18:29:13 +0100
From: Alexis Praga <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Help in reading XML into a data type with
HXT
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Hi,
I am trying to read a very simple xml node containing a list of other xml nodes
into a data structure. Running the code yields :
fatal error: document unpickling failed
xpCheckEmptyContents: unprocessed XML content detected
context: element "animelist"
contents:
<title>Bleach</title>
<title>Naruto</title>
Can you help me debug this ? The code and xml are below :
8<---Code---------------------------------------------------------------------
module Main where
import System.Environment
import Text.XML.HXT.Core
type Anime = String
type AnimeList = [Anime]
xpAnime :: PU Anime
xpAnime
= xpElem "title" $ xpText
xpAnimeList :: PU AnimeList
xpAnimeList
= xpElem "animelist" $ xpList $ xpAnime
main :: IO ()
main = do
[src] <- getArgs
a <- runX ( xunpickleDocument xpAnimeList [] src)
mapM_ putStrLn a
return ()
8<----------------------------------------------------------------------------
8<---XML---------------------------------------------------------------------
<animelist>
<title>Bleach</title>
<title>Naruto</title>
</animelist>
8<----------------------------------------------------------------------------
Thanks,
--
Alexis Praga, PhD Student (CERFACS)
GPG key : AD4A AF6D BB5C 042F 9422 1223 06E1 C1BF E287 65D0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150124/eb29823e/attachment-0001.sig>
------------------------------
Message: 2
Date: Sat, 24 Jan 2015 13:19:02 -0500
From: Michael Orlitzky <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Help in reading XML into a data type
with HXT
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
On 01/24/2015 12:29 PM, Alexis Praga wrote:
> <animelist>
> <title>Bleach</title>
> <title>Naruto</title>
> </animelist>
HXT is picky about whitespace, you have to tell it to ignore those
leading spaces.
Try,
runX ( xunpickleDocument xpAnimeList [ withRemoveWS yes ] src)
instead.
------------------------------
Message: 3
Date: Sat, 24 Jan 2015 19:56:43 +0100
From: Alexis Praga <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Help in reading XML into a data type
with HXT
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
On Sat, Jan 24, 2015 at 01:19:02PM -0500, Michael Orlitzky wrote:
> HXT is picky about whitespace, you have to tell it to ignore those
> leading spaces.
>
> Try,
>
> runX ( xunpickleDocument xpAnimeList [ withRemoveWS yes ] src)
>
> instead.
Thanks, I was going in circles there !
--
Alexis Praga, PhD Student (CERFACS)
GPG key : AD4A AF6D BB5C 042F 9422 1223 06E1 C1BF E287 65D0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150124/8fbafe54/attachment-0001.sig>
------------------------------
Message: 4
Date: Sun, 25 Jan 2015 04:01:03 +0000 (GMT)
From: Animesh Saxena <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Show and showList
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
Thanks Brandon....this is a very nice subtle distinction!
-Animesh
On Jan 23, 2015, at 05:28 PM, Brandon Allbery <[email protected]> wrote:
On Fri, Jan 23, 2015 at 8:21 PM, Animesh Saxena <[email protected]>
wrote:
It's the same problem now transfered to showList which will be declared
differently for a list of int's or a list of chars, but still it outputs them
differently as can be seen from the above code.? How it is able to
differentiate without throwing up the overlap error?
The key is that showList is defined on e.g. Int or Char, not [Int] or [Char].
If we tried to do the "obvious" thing for a list, we'd define
? ? instance Show a => Show [a] where ...
but then we have an overlap any time we try to define a different handler for a
specific list of things (in this case, instance Show [Char] would be the
overlapping instance we'd want, to produce the String representation). We avoid
this by building the representation for lists into the representation for
single items (thus, a showList method); we can provide a default implementation
of that method in the Show class to do the usual brackets-and-commas
representation, using the mechanism intended to allow optimized versions of
typeclass methods for particular types, and then provide a specific
implementation for instance Show Char without invoking overlap.
--
brandon s allbery kf8nh ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sine nomine associates
[email protected] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [email protected]
unix, openafs, kerberos, infrastructure, xmonad ? ? ? ?http://sinenomine.net
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20150125/a569420f/attachment-0001.html>
------------------------------
Message: 5
Date: Sun, 25 Jan 2015 05:33:17 +0000 (UTC)
From: Robert Dodier <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] ghc failed to compile trifecta while
installing idris
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Sumit Sahrawat, Maths & Computing, IIT (BHU <sumit.sahrawat.apm13 <at>
iitbhu.ac.in> writes:
> Take a look here:?https://github.com/ekmett/trifecta/issues/41
Thanks for the hint. The problem is fixed in Git.
I guess an updated trifecta package will be put in Hackage.
In the meantime,
cabal install idris --constraint='blaze-markup <0.6.3'
is a workaround (thanks to David Christiansen for that).
best,
Robert Dodier
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 79, Issue 28
*****************************************